Resetting a value on a field and incrementing with each new record (1 Viewer)

kaldana77

New member
Local time
Yesterday, 22:36
Joined
Oct 2, 2019
Messages
2
I have an ID field that needs to be reset each new year, once records are archived (starting back with 1 then increment with each new record). I am able to get the 1st record entered starting with 1 after I purged (testing) records. However, when I go to add another record, it wants to keep putting it at 1. I was using the DLookup function, which I do understand why it thinks there is a null value in that field, so I was trying to incorporated the Dmax function within my command but it keeps giving me an error like I am missing a ( or a " or '. I am at a loss. Any help would be appreciated. I want it to look at the last value in the table and increment. I'm having brain fog as it's been a very long day today. Any help is very appreciated.

If IsNull(DLookup("ExhibitorID", "[tblExhibitorDetails]", "[ExhibitorID] = " & DMax("[ExhibitorID]", "tblExhibitorDetails")) Then
Me!ExhibitorID = 1
Else
Me!ExhibitorID = DMax("ExhibitorID", "tblExhibitorDetails") + 1
End If
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:36
Joined
Sep 21, 2011
Messages
14,238
Look at similar threads at the bottom, this gets asked a lot, and recently as well
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:36
Joined
Oct 29, 2018
Messages
21,455
Hi. Welcome to AWF!

Not sure an If/Then/Else block is necessary without seeing your setup. Normally, a simple Nz(DMax(),0)+1 is all that's needed.
 

Users who are viewing this thread

Top Bottom