Dmax not working (3 Viewers)

dullster

New member
Local time
Today, 04:57
Joined
Mar 10, 2025
Messages
5
I am trying to create a Dmax in a subform to increase my "RecordNum" field. It either doesn't work or it produces the same number all the time.
 
What is the expression you are using? What type of field is RecordNum? Integer? Autonumber?
 
Are you trying to store something based on a "DMax() + 1" type of formula?

For "Doesn't work" the question is, then what does it actually do?

For "same number" that means that something didn't get stored or didn't get incremented BEFORE it was stored. (We can't tell which of those two from here.)
 
Are you trying to store something based on a "DMax() + 1" type of formula?

For "Doesn't work" the question is, then what does it actually do?

For "same number" that means that something didn't get stored or didn't get incremented BEFORE it was stored. (We can't tell which of those two from here.)
Currently I am getting an error with this code =DMax("tblDemoTrans","RecordNum")+1
 
Are you trying to store something based on a "DMax() + 1" type of formula?

For "Doesn't work" the question is, then what does it actually do?

For "same number" that means that something didn't get stored or didn't get incremented BEFORE it was stored. (We can't tell which of those two from here.)
Already been advised of not incrementing in the other forum Doc. :(
 
=DMax("tblDemoTrans","RecordNum")+1 . It is a number field.
Why are you trying to do this instead of having "RecordNum" be autonumbered?
I'd also give it a better name than "RecordNum". DemoTrans_ID may be a better name as it makes it very apparent it is the primary key for the DemoTrans table, the main reason you use an autonumbered field.
 
Why are you trying to do this instead of having "RecordNum" be autonumbered?
I'd also give it a better name than "RecordNum". DemoTrans_ID may be a better name as it makes it very apparent it is the primary key for the DemoTrans table, the main reason you use an autonumbered field.
Speculating it might be a customer-facing transaction ID and not the PK for the table.
 
=DMax("tblDemoTrans","RecordNum")+1 . It is a number field.

As noted, you have the table and field arguments reversed, so this should do nothing. HOWEVER,...

Where is that snippet of code used? If it is on a form as the .ControlSource of a control on the form, that means the particular control is not bound to a record and therefore will not be stored when you increment it. So you have TWO reasons why this won't work.
 
Speculating it might be a customer-facing transaction ID and not the PK for the table.
Normally when I see DMax() used for customer facing numbers it is stored as a "PO" or "Receipt" number rather than "RecordNum". Hence the question as I'd hate to think OP is trying to reinvent fire!
 
Yes - or it is part of the construction of that customer facing identifier - often with a year/ alpha prefix...
 

Users who are viewing this thread

Back
Top Bottom