Effectively creating a counter?

^Nightwing^

Registered User.
Local time
Today, 01:45
Joined
Sep 20, 2004
Messages
10
To simplify data entry I am automating the entry of an ID number which is only neccessary to make a many-to-many table relationship function. The niftiest way to do this is with a counter, however using a control and VB to edit it doesn't fully work, because the counter resets every time I reopen the form. Is there a way to either make the default value equal to the maximum value in a particular field of a table or a better way to make a counter?
 
NightWing,

The most common way is to use the form's BeforeInsert event and use the
DMax function to retrieve the largest value and add 1 to it.

NewKey = Nz(DMax("[ThatField]", "ThatTable"), 0) + 1

Wayne
 

Users who are viewing this thread

Back
Top Bottom