First, you have to use YOUR field and control names. The ones I use are samples. The error you are getting indicated you do not have a control named txtProject. So you have to substitute the correct name of the control. bound to the ProjectID field. By the way it is not a good idea to the octothorpe(#) as part of a field name. A controlname may be different from a fieldname. The name property of a control is on the Other tab in the Properties dialog.
This requires no pre-knowledge of a primary key and only assumes that when you load the form initially, it is already sorted. Any records newly inserted will get the next bigger number. However, if you requery and it causes the newly inserted rows to be re-sorted, they will be now given a new number that relates to their actual position within the set, which can be either good or bad, depending on your specific requirements.
There’s an old Steve Martin joke about how to make a million dollars which starts, “First, get a million dollars…” That’s the key to this trick, too: First, get a bunch of numbers. Here’s a file with 1,197 numbers in it. Now import or paste those numbers into a thread so that the numbers appear in the right place. If you need two matching numbers, just import it twice.
This will work OK for a small set of data, but the more data there is, the more intensive the subquery becomes, and it must be called repeatedly for each row. This is one of those rare cases where doing it in VBA is faster than doing it in SQL — after all, row numbering is fundamentally iterative, not set-based which just goes against the grain of what SQL was designed to do – solve a problem in a set-based fashion, non-iterative fashion.
I have screen shots of what I have in my db, where can I send it to you (it is in word format) so that you can take a look at it to see what I am doing wrong. I took a screen shot of what is listed for the button and I took a screen shot of the text box Job No. I don’t know how to bound anything other than put the code behind the button and putting the Job_No in the code as you stated. I understand what you are saying, but I thought if I put the text box name Job No in the code behind the button then it would be bound to my table with the Job No field. Heeeelllllppppp!!!! I am sorry that I can’t seem to grasp this….but appreciate all of your help!
I put some text into the rows numbered 5 and 6, then clicked on a cell in the row labeled "5" to select that row, and pressed option-down arrow to insert a row below it. As can be seen below, the formula is copied into the new (empty) row, and calculates the correct number. The formula in the rows below automatically adjust the rest of the row numbers.

Next we will look at scenario 2. The variation here is that Apex wants to start each year with anew sequence of numbers. Also, they want to include the year when displaying this number. We still use a DMax, but we need to add criteria to determine the year. So Apex needs to have a field in their table that indicates the date. Generally, such inquiries will have a date/time stamp to indicate when received or the user will input the date and time. So we will assume there is a field in record called InquiryDate. We will also add an Integer field named Sequence. On the form we will add a control bound to Sequence, but set its Visible property to No. The line of code will look like this:
As you can see, an idea of sequential numbering can be solved many different ways using different domains. This is typical in this field of work and precisely why it pays to not just consider how you can do it in one domain but also whether the domain is the right domain. We saw how we can easily leverage built-in features such as Transact-SQL’s ROW_NUMBER() or Access report’s Running Sum property. We also not only saw how we can craft our custom solutions in either VBA or SQL but we also see how we can use both together to create a solution that is better.
The Nz function will return 0 if there are no records so this expression will return a 1 the first time and then increment the highest number each additional time. The key is where to put this line of code. As I said it needs to be generated immediately prior to saving the record so that another user does not get the same number. So generally I would put this behind a Save button or a button to specifically generate the number. I would then add a second line to commit the records. Either:

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.


The blog is pretty much step by step. Where it may not be that specific is, because, these are decisions the developer needs to make. For example, where to put the DMax expression is a matter of your workflow so I can’t tell you where to put it. I’ve given tips in the blog to help you decide. If you are having issues, then please give me more info about your application and I can suggest things.
Scott, you’ll need to be more specific to help me. When you say “put this code behind a save button” what exactly does that mean – where do I type the code you provided? Yes, I do have a Save Button, which saves the record and closes the form (but currently has no way to save the next sequential Project ID). I want show this next Project ID (number on the entry form) and have that new number flow to the table along with the other data on the form.
Unfortunately that's not where macro's go, it's a bit of a learning curve, take a look at this site how-to-automate-autocad-with-command-macros/ he covers the basics of macro's and gives a nice example of how and where to place them, there is also a link to the more traditional method. You might need to read through a couple of times but once understand it, macro's can be really useful, I'd be lost without them.

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.
Creating a sequential list of numbers, in Word, sounds like an intimidating task. Sure, you can create a numbered list quickly enough, but that feature works with additional text - you're numbering something. If you want a list of just numbers, you have to work a bit harder. Word's SEQ field might come to mind, but that solution is better suited to template-type numbering. In order words, this field works great if you're numbering documents, labels, and so on. It doesn't work so well if you just want to create a list of sequential numbers. You can use it that way, but it'll be more work than it's worth.
×