using sequential numbers for documents

S

snimmuc

Your help please. I want to sequentially number a series of receipts, for
customers who buy from us. I have set up a form to select the product (work
of art) and I have also set up a Report to print the Receipt. Two questions -
How and where do I store the coding to generate a sequential number for the
receipts? Second question is there a more user friendly way to select the
record to be printed than using a Query. Final question (that's three), what
code should I use ? I am new to Access. I've got this far OK, but I cannot
work out a solution to the above. Thank You.
 
A

Arvin Meyer [MVP]

There are so many different ways to do this. Keep in mind, however, that if
a record in the sequence is deleted, a hole will remain that must be ignored
or manually filled,

Probably the easiest way is to look and see what the last number is and add
1 to it. Use this to create a default value for that record, so it won't be
used unless you start typing the record:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer
x = DMax("ProviderNumber", "tblProviders", "ID =" & Me.txtID)

If IsNull(x) Then
Me!txtProviderNumber.DefaultValue = 1
Else
Me!txtProviderNumber.DefaultValue = x + 1
End If

End Sub
 

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