Error unless there is a number listed

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

I am getting an error with this part of my code:
lngInvoiceID = DMax("InvoiceID", "tblInvoice") + 1
But only if it is my first Invoice can I add a null factor in!
 
Hi Bob,
one way is to first test for any existing invoice number.

If DCount("*", "tblInvoice") >0 Then
lngInvoiceID = DMax("InvoiceID", "tblInvoice") + 1
Else
lngInvoiceID = 1
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
lngInvoiceID = Nz(DMax("InvoiceID", "tblInvoice"), 1) + 1

The above code step will use the number 1 when it's the first invoice
number.
 

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

Back
Top