increment a string field

  • Thread starter Thread starter APNA
  • Start date Start date
A

APNA

Guest
Hi all,

I am designing a table where I want to create a field which should autoincrement on every new record. Note I would like to use ms acess as back end.The field I want to use should be a string field for instance 'A001' and the next record should read 'A002' and so on.

Can anyone give me code for this function.Lets call text field as ID.initialise to A001

Thanks please help.

Apna
 
Try something along the lines of

Dim intMe As Integer
Dim strNewRef As String

intMe = Right(DMax("field", "table"), 3) + 1
strNewRef = "A" & intMe

I'm assuming here that the all records will begin with the same letter.

You'll need to do a bit of work on this as I in my test it was dropping the leading zeros when it converted it to a number.

Perhaps someone can help you with that...
 

Users who are viewing this thread

Back
Top Bottom