Increment Alpha-characters

K

Ken

I have a text field that I use to keep track of the lastest revision of quotes.
rev a, rev b, etc.
How would I go about incrementing the alpha character so when the user wants
to generate another record/revision, the form would automatically increment
by 1.

Thank you,
Ken
 
B

Brendan Reynolds

Increment the ASCII code. Don't forget to check for no character, or
character already at maximum. For example ...

Private Sub Command2_Click()

If Len(Me.Text0 & vbNullString) = 0 Or Me.Text0 = "Z" Then
Me.Text0 = "A"
Else
Me.Text0 = Chr$(Asc(Me.Text0) + 1)
End If

End Sub
 
K

Ken

Code works well for a "b" record after an "a" record, but not for a "c".
Should I be using a DMax function to first determine the highest revision?
If yes, how would I modify the code below?
'Me.QuoteDash = Chr$(Asc(Me.QuoteDash) + 1)

Thank you,
Ken
 
B

Brendan Reynolds

Sorry, Ken, I don't understand the question. I tested the code with all
values from Null, then A through Z and back to A again. I'm not sure what
you mean by 'but not for a "c"'?

You will certainly need to determine the maximum existing value before you
can increment it, yes.
 

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