Jump to content
Server Maintenance This Week. ×

Conditional Auto-increment via Calculation?


This topic is 2430 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi there! I've been beating my head on the desk for about a week trying to figure out an issue with auto-incrementing values in a child table, dependent on a value in the parent table, and it is driving me absolutely insane.

In a previous iteration of the DB, auto-increment was working fine, as the value to increment the field was hard coded (i.e. incrementing the value by 1 for each successive child table record created). However, through real-world use, it became apparent that this was not ideal, and that I needed to have the option of incrementing the value by 1 or by 2. So, I devised a field in the parent table for the user to select which increment should be used (1 or 2).

Unfortunately, since this time, the auto-increment has never worked. I've been experimenting with various 'If' statements, 'Case' statements, etc., and have had zero luck. I have usually had good luck in solving my own issues by creating the simplified example to post here, but this time, all of my trial and error has yielded zilch. It seems like it should be really simple, but...

I'd really love some insight into why my setup isn't working anymore. I created an example file (as I can't post the actual file used). The structure is really simple, but mimics the actual DB.

59a5fda32e955_Auto-incrementExampleStructure.jpg.f40f76a64c37fa6b1123f7457812be5d.jpg

Thanks, as always, for any insight or push in the right direction!

Auto-increment Based on Parent Value.fmp12

Link to comment
Share on other sites

Nevermind... Solved it. Strange implementation (to my novice brain), but it works. Assigning the chosen graduation to a global variable, then using the value of the variable in the child table calculation was the way to go.

EDIT: After further examination, the global variable wasn't needed. The original code works... if the record is committed. I guess when I moved on to the next record, the previous record wasn't committed, so the calculation choked. Adding a script step to commit the record after inserting the chosen increment, then pressing on with data entry, allowed the next record to evaluate the previous record's value, and increment it properly. Derp. Sometimes it's the simple things...

Edited by vwgtiturbo
Clarification
Link to comment
Share on other sites

This topic is 2430 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.