Ignore the letter and look at the number

  • Thread starter injanib via AccessMonster.com
  • Start date
I

injanib via AccessMonster.com

I have a field on my form that gets its value from the code below.

Me.txtInvoice = DMax("[Invoice Number]", "InvoiceTable") + 1

The invoice numbers in the table starts with a letter "I". How can I make the
code ignore the letter and just look at the numbers?
 
K

Ken Snell [MVP]

You should store the I value in one field and the number value in a second
field, then you can concatenate the two values together to display an
invoice number.

It'll take some special code to "ignore" the I value - Note that I do not
recommend this approach:

Me.txtInvoice = "I" & Format(DMax("CLng(Mid([Invoice Number], 2))",
"InvoiceTable") + 1, "00000")

The above assumes that the invoice number has a format like "I00001" or
"I02956". If you have a different number of number digits, then the "00000"
needs to be changed so that it has the same number of zeroes.
 

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