increment on add new record

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!
 
M

Marshall Barton

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
 
J

JohnLute

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top