Incrementing Record Number with Code?!

  • Thread starter Thread starter PlanningCM
  • Start date Start date
P

PlanningCM

Guest
I have a field in my table that I am trying to increment every new record in the sense like AutoNumber but it has a Letter in the field so it can't be autonumbered! So here is an example of what the record number format in the field looks like

S03-001
S03-002
etc...

I want it to increment the last 3 numbers every new record so the user doesn't have to input it. I figured implement some sort of code checking the last 3 numbers for what they are in the last record in the database but I forget the code for just picking out the last 3 characters in the string?! And after the check for last record and what the last record in the field contains how would I add 1 to the number if it is a string I keep getting a type mismap from trying to add a number to the string it gets all confused and doesn't know where to add it. Please Help me out!

JW
 
Autonumber

If I understand it right, in your number - last three digits are to be autonumbered ?
for eg:
S03-001
S03-002

So 'S03-' part remains unchanged ? If that is the case than why not concatonate lbl"S03-" & "autonumber" ?

Maybe somebody else has a better solution.

Good Luck !
:)
 
Sounds like an idea to try could elaberate a little more on how I would go about doing that I am not sure that I understand you fully?!

JW
 
I ended up setting up an Input mask making is so that "S03-" was always there and that the other 3 numbers would be grabed from the code then simply incremented those 3 numbers that it grabed that seemed to work simple.... wow damn easy things sometimes scare me when you think they should be hard!

JW
 
That is one way of doing it.

Another way would be:

txtBox = "S03-" & txtAutoNumber ' It should return S03-01, S03-02, etc..

:)
 

Users who are viewing this thread

Back
Top Bottom