Autonumber after certain fields have been entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that Engineers enter their data into and after they have met
certain criteria i.e. certain fields are filled out then I would like the
form to assign the next Engineering Change number available.

I currently have the autonumber but as soon as they enter the first field
the next number is given, I am trying to avoid them not enter all data needed.

Any thoughts on the best way to achieve this? Autonumber or other?

Thanks!!
Stacey
 
You can't do it with Access's built-in AutoNumber fields. An Autonumber
field assigns the next number as soon as you start entering data. You'll
need to roll your own function to create the next available number during
the BeforeUpdate event of the form. Search Access Help for the DLookup
function.
 
I am building an application with a similar requirement. Here is what
I did.

I created a form that sets the "Navigation buttons" property of the
form to NO. Then I set up the form with my own buttons that are to be
used to UNDO data entry, CANCEL the form, or SAVE the data.

When the form first loads, the UNDO and SAVE buttons are set ENABLED =
FALSE. Only the CANCEL button is set ENABLED = TRUE.

As soon as a user makes an entry into any field, then I set ENABLED =
TRUE for the UNDO button. This is done with a line of code in the
"FORM_OnDirty" event.

I identified / determined the fields that are required for the users
to enter.

I created a function called DataOK() as Boolean.

Then in the "OnChange" event for each field I make a call to DataOK.

What this function does is it checks the values entered into each
required field. If any required field is NULL, EMPTY, or has an
invalid entry, then it returns FALSE. It returns TRUE only if there
is a valid entry in each of the required fields.

Then, still in the OnChange event for each field, if DataOK = TRUE, I
set ENABLED = TRUE for the SAVE button. Otherwise I set ENABLED =
FALSE (in case they changed a previously-valid entry). So when all
fields are valid then DataOK = TRUE and the SAVE button is enabled for
them to click on it to save the record.

Then if a user clicks on the SAVE button, in the SAVE_Click event I do
the additional data activities (such as generating the next unique
sequential record identifier, in this case a document reference) and I
save the record.

It sounds like maybe a lot of work and maybe there's an easier way to
do it, but this works pretty well for this application.

Hope this helps.
 
Back
Top