next invoice number

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hi

I have a form that will lead onto an invoice. I want to pick the last
invoice number created and add 1 to it and suggest this as the next number.
What is the easiest way to do this and also how would i do the first number
as it will find a null

Thanks
 
Dave

The simplest way would be to make the invoice number an AutoNumber. Access
will increment it for you. The user will not have to type anything in that
field.

That said...If you do not want to use an AutoNUnmber, you can use the DMax()
domain function to find the highest number.

Put this in your form's Current event:


Private Sub Form_Current()
Dim varMaxNum As Variant

varMaxNum = DMax("CustNum", "Orders_noAutoNum")
If Me.NewRecord Then
If IsNull(varMaxNum) Then
Me.CustNum = 1
Else
Me.CustNum = varMaxNum + 1
End If
End If

End Sub

DMax has 3 parts: the field, the table and optional crieria. If no number is
found, it returns a Null. If it is null, the invoice number should be 1. If
it is not null we add 1 to the highest number (MAX 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

Similar Threads

Invoice Append 1
Continuous Invoice Nos. 3
2910 line of info 13
Reducing Balance on Invoice 9
invoice form 2
Invoice Form Question 4
VBAscript for data matching excels 0
Access Access variable string for export 0

Back
Top