Forcing sequential flow of data entry from top to bottom of a form (1 Viewer)

jumnhy

Member
Local time
Today, 13:43
Joined
Feb 25, 2021
Messages
68
Hi folks,

Hoping that like always you fine folks can help me figure this out.

I'm trying to set up a form (basic, bound single form used for both entering new data and updating existing records) where only the top control is enabled to begin with, and each control below this is only enabled when the data from the controls above has been filled in.

Eg, no skipping down the page until you've entered everything in sequence.

Thinking of something in the BeforeUpdate that to toggle the "Enabled" property of the "next" control to True.

"Next" is kind of a tricky construct: thinking of using the tab stop index as a proxy for this? Any other ideas? I'd like to make this somewhat generalizable so want to avoid just hardcoding the order into the process.

Had also considered putting it into the form's BeforeUpdate instead, and looping through each control, enabling only the controls that already have data entered + 1 more (in the tricky-to-define sequence mentioned above). Better, worse, or indifferent solution in all your expert opinions?

I think I'd need something to set the initial state of enabled/disabled fields outside the control level anyway as people do use this to update existing records too, so they could move to a new record before completing an old one.

That's totally fine, I just don't want any blanks in the record for our audit trail, as each field is documenting a particular process step.

Would appreciate any input you guys have to offer on this.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:43
Joined
Feb 28, 2001
Messages
21,193
If I had this problem, I would do it by having a "Form_Current" event that reset ALL of the controls to be invisible/disabled/locked (some combination of those). Except for the first control. I would then use the LostFocus event of each control to enable the next control in sequence IF the current control was correctly managed. Some folks would perhaps use the Change event. But in either case, you have a choice when the event fires - to enable the next control in sequence (if the value is OK) or leave it locked and maybe pop up an error via MSGBOX if there is a problem.

Doing it this way means you cannot save the record in question until it is completely filled in. I.e. if you are not finished when the clock hits quitting time, you can't quite just yet. If that is not what you meant, then the other possibility is trickier. If you wanted to be able to save the record at any time and come back to it for more work, then you need a "state" variable in the record. Could be just a number. This state variable would increment in some event based on completing another control. If you save it, you save the (probably hidden) state variable. Then if you open the record again, you have code that resets all the controls according to the state variable.

Neither of these approaches would be trivial but once you got the idea going, there would be no dramatic questions. It would be just a matter of tedium to build the form completely in this way. The biggest "gotcha" would be if you had to add a new step in the middle of the process, but even that wouldn't be terrible. Again, more tedium than mystery.
 

jumnhy

Member
Local time
Today, 13:43
Joined
Feb 25, 2021
Messages
68
Thanks for your input, doc!

Was trying to avoid the tedium so that the next guy doesn't have to re-write the thing when we do inevitably add a new step to the process down the line, cuz the next guy will be me. But tedium is kind of the name of the game sometimes with Access. I might be able to shortcut a little simply based on the physical "higher on the page is sooner in the process" piece, and build the sequence dynamically, but that's just frontloading/futureproofing a little at the cost of more work now.

As you say, I'm definitely looking for users to be able to leave and revisit "partially completed" records to continue. I was thinking of endrunning the need for a state variable by scanning the controls, and enabling the "first" one that wasn't a zero/null/ZLS. The state variable is a better solution though--don't have to revalidate the state every time you load the form, you just read the state itself.

For context, we're tracking preventive and corrective actions. Don't want users being negligent and failing to document each step completely before moving on to the next.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:43
Joined
Feb 19, 2002
Messages
33,755
I think you may be over engineering the "solution". What problem are you trying to solve? There is no reason that I can think of where this obsessively tight control would ever be necessary and I've been doing this for 50 + years so I have a lot of experience creating user interfaces. All you actually need to do is to validate data in the form's BeforeUpdate event to ensure that all data is present and valid.

The Form's BeforeUpdate event is the flapper on the funnel. ALL records go through the BeforeUpdate event before they are saved and this is the LAST event prior to save. If you Cancel the event, the record will not get saved. PERIOD. If all you care about is that the fields are not null, that is easy to do with a loop. If you have rules for some fields such as TranDT must be <= today but not more than one week old, you'll need code for the specific edit rules. Someone will post the "presence" code loop if that is what you want. Usually, you would add a value to the tag property of each control you want to check and the loop would look for that value. That allows you to ignore some fields. For example, the First and Last name might be required but the Middle name is not.

If you decide to use the code loop to check for presence, add a very large note to the procedure to warn your successors to add a tag to any controls they add that should be checked.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:43
Joined
Feb 19, 2013
Messages
13,581
Assuming you have set this up, what do you do if a user having entered a value in the first and second controls then goes back to the first control and amends or deletes the entry?
 

Users who are viewing this thread

Top Bottom