Microsoft Office Tutorials and References
In Depth Information
Creating Controlled Numbers
Figure 98 – Controlled Numbers
Two main options are available for controlling unique ID numbers: Using
DMAX + 1 when inserting a new record, and using a system table with the last
used number.
The DMAX function retrieves the maximum number from the table. In the
OnInsert event of the form, the value is set. This event is triggered the moment
the first field value is entered. Then the code executes, the number is set, the
Save button is enabled, and the issued number appears in the key field. The
Cancel button first executes the Me.Undo to ensure nothing is saved.
The DMAX function works, but using a table with the last used number offers a
more flexible approach because it allows the user to change the highest number
and/or year whenever necessary. We need only be concerned that the numbers
are unique. Thus, a new number can only be a number higher than the
previous one (within a given year). Two functions have been created in a
module modOrderNumber.
Search JabSto ::

Custom Search