Add one to last

pwicr

Registered User.
Local time
Today, 02:18
Joined
Sep 22, 2011
Messages
144
I have a field that I want to automatically generate the number using the last one.

My numbering is SPF828 so I want the next one to auto-generate SPF829.

this is a text field.:confused:
 
You can use the DMax() function plus one to create your own auto incrementing number.

Something like;
Code:
    If Me.YourCounter = 0 Or IsNull(Me.YourCounter) Then
        Me.YourCounter = Nz(DMax("YourCounter", "YourTableName"), 999) + 1[COLOR="DarkGreen"] '999 represents the seed  (first number) of your series[/COLOR]
    End If

Additionally instead of storing a text field you could simply use a numeric field and then use the Field's Format property to add the text prefix, something like;
Code:
"SPF"0
 

Users who are viewing this thread

Back
Top Bottom