increment on add new record

  • Thread starter Thread starter JohnLute
  • Start date Start date
J

JohnLute

I have a table with a text field for numeric and alphanumeric values. Some
forms that source this table will always enter numeric values into this
field. For these forms I want to be able to automatically increment to the
next numeric value upon creating a new record.

How can I do that?

Thanks for your help!
 
JohnLute said:
I have a table with a text field for numeric and alphanumeric values. Some
forms that source this table will always enter numeric values into this
field. For these forms I want to be able to automatically increment to the
next numeric value upon creating a new record.


Use the form's BeforeUpdate event:

If Me.NewRecord Then
Me.thetextfield = DMax("Val(thetextfield)","thetable", _
"Not thetextfield Like ""*[!0-9]*""") + 1
End If
 
Thanks, Marshall. This worked a charm! Sorry to be so late to respond - I've
had browser issues with the forum.
--
www.Marzetti.com


Marshall Barton said:
JohnLute said:
I have a table with a text field for numeric and alphanumeric values. Some
forms that source this table will always enter numeric values into this
field. For these forms I want to be able to automatically increment to the
next numeric value upon creating a new record.


Use the form's BeforeUpdate event:

If Me.NewRecord Then
Me.thetextfield = DMax("Val(thetextfield)","thetable", _
"Not thetextfield Like ""*[!0-9]*""") + 1
End If
 
Back
Top