To recap, you use a DMax function to return the highest number in the Sequence and increment it by 1. You assign the incremented number to a control on your form and then immediately save the record. If your identifier includes additional information from the record, you use an expression that concatenates that information with the sequence number to display the full identifier.

I am having trouble with this procedure. My situation is almost identical to example #2. I want to populate RecordNumber on my form with a date number like “130001, 130002, etc.” where “13” is the year based on a date automatically generated in the OpenDate field in tblLogRecords. OpenDate is a date/time type field that has a default value of the date the record is created and is not editable. I have added a field called Sequence to tblLogRecords and it is a Number, Long Integer type. I also created a bound control for Sequence on my form. I have a completely separate autonumber field as the PK.

Now, what’s the deal with the UniqueKeyVariant parameter for the RowNumber() function? We are not even using it all! True, but if we didn’t, Access will call RowNumber() only once for an entire query and thus we get “1” for the entire dataset. That is a good way to save on CPU processing – why call Now() for each row? In this case, we want to go against this CPU-saving measure and ensure that the RowNumber() is in fact called once per row to generate a new number for that row. Thus, we pass in a parameter — a primary key of a table is a good choice for this purpose. So we get a nice sequential number generated all in the query with VBA function.

Some freeways' exit number starts from a advanced number (i.e. higher than 1). Some reason of starting a number higher than 1 is due to the expectation that the highway will extend on both ends. For example, Ontario Highway 400 starts at 20 because it was expected that the south end of the highway would extend to downtown Toronto (which was never built). Another reason to use a higher number is that the freeway is branching off from another freeway. An example is British Columbia Highway 5, which branches off British Columbia Highway 1 and starts at 170.
To recap, you use a DMax function to return the highest number in the Sequence and increment it by 1. You assign the incremented number to a control on your form and then immediately save the record. If your identifier includes additional information from the record, you use an expression that concatenates that information with the sequence number to display the full identifier.
Yes, I have used this system in a multi-user setting. As noted, the key is to commit the record immediately after generating the sequence. However, if the application is one where there is very heavy transaction processing. In other words dozens of users creating records simultaneously, you might want to guard further against duplication. At the speeds computers process, it is not impossible that multiple users will grab the max value before it can be incremented and saved.
OK I found the ControlSource property but it is on the Job No text box, do I enter the code there or am I entering my code on the button I created to save and get new number? If I put it behind the button, when I open the form it goes to the first record so I go to the last record and hit save get new number button and it gives me the number 1……Is it because when I open the form it goes to the first record and not a new record????
If you make a list of things you need to do, starting with number 1 and continuing until all your tasks are accounted for, then you’ve made a sequential list. Something that is sequential often follows a numerical or alphabetical order, but it can also describe things that aren’t numbered but still need to take place in a logical order, such as the sequential steps you follow for running a program on your computer.
×