Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber Multiple sequential values

Status
Not open for further replies.

CGill

Programmer
Jan 2, 2003
51
GB
I have been trying to create a form\query or code which could do the following

Create a random number in the format 110001
Increment the above in the format 110002
Allow the creation of different starting points i.e
110001,02,03
120001,02,03
130001,02,03

So far I've established that the way to do it is to use a number field as opposed to Autonumber and have some sort of if...then set value code. My only thinking on this was to have a field so if I choose say a option in my combo box which has a unique code of 11 it will grab this and set the ID field to 11 + min value of field.

I understand I haven't explained what I want well but I am hoping someone might understand and be able to guide me in the right direction..

Thanks for any help
 
Hi,

You could try a function such as :

Function Contact_ID ()

Dim idfield As Variant
idfield = DMax("[ID]", "TableName", "[ID] Like '11*'")
If IsNull(idfield) = True Then
Contact_ID = 110001
Else
Contact_ID = idfield + 1
End If

End Function

Hope this helps !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top