Creating a controlled sequencial number

G

Guest

I am trying to create a sequencial invoice number from a starting point. I am
running a append query and want to input a starting invoice number on a form,
and then the query will advance the invoice number by 1 for each invoice
generated. I have it working by using an auto number for the invoice but I
need to input the starting number and go from there.

Or is there a better way.

Thanks
 
J

Joseph Meehan

QC said:
I am trying to create a sequencial invoice number from a starting
point. I am running a append query and want to input a starting
invoice number on a form, and then the query will advance the invoice
number by 1 for each invoice generated. I have it working by using
an auto number for the invoice but I need to input the starting
number and go from there.

Or is there a better way.

Thanks

I suggest you may not want to use Autonumber for that use. Autonumbers
are designed to provide unique numbers. It in not designed to provide
numbers in order and for a number of reasons may not do so. As a result
using them in any application where the user sees the numbers is likely to
end up with confusion.

There are other ways of providing the numbers you want depending on the
particual application. Normally they will require writing a little VBA
code. Hopefully someone will come along and offer you some sample code. I
don't have any as I have never needed to use it.
 
T

Tom Collins\(Home\)

| I am trying to create a sequencial invoice number from a starting
point. I am
| running a append query and want to input a starting invoice number
on a form,
| and then the query will advance the invoice number by 1 for each
invoice
| generated. I have it working by using an auto number for the
invoice but I
| need to input the starting number and go from there.
|
| Or is there a better way.
|
| Thanks

If it's strictly a number then you can use an AutoNumber field. These
normally start at 1, but there is a way to set a different starting
number. Access won't let you enter a different number either in form
view or dataset view. It will let you append a different number using
an Append query. Here's the steps you would go though:
1. Create a copy of the table that has your invoice number (We'll call
the original table A and the copy table B). The table will have to be
empty for this to work.
2. Depending on what it when you started, make sure Invoice Number in
table A is AutoNumber and Long Integer in table B.
3. Populate a dummy record in table B with the Invoice Number ONE LESS
than what you want to start with. If you want your invoice numbers to
start at 1000, put in 999.
4. Using an append query, append table B into table A.
5. You can now delete that dummy record in table A. The next record
will automatically be 1000 and so on.

2 words of warning.
1. DO NOT compact the database while table A still empty. Doing so
will reset the 'next record number' to 1.
2. If someone starts a new record and then cancels out of it, the
number is still used up. This will cause a gap in the sequence
numbers.


Also, as Joseph said, you could also do this with VBA. Look at locking
the field, the Before Insert event, and running a query to get the
next number.

Tom Collins
 
M

M.L. Sco Scofield

Depending on what you need, these articles might have some useful
information.

For an ADO version. This will also work in 2002 and 2003.
http://support.microsoft.com/default.aspx?scid=kb;en-us;210194
(There is some supplemental information at
http://support.microsoft.com/default.aspx?scid=kb;en-us;240317.)

For a DAO version. This will work in 2000, 2002 and 2003 as long as you have
a DAO reference set.
http://support.microsoft.com/default.aspx?scid=kb;en-us;140908
(There is some supplemental information at
http://support.microsoft.com/kb/191253/EN-US/.)

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

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

Auto number 1
sequencial #'s (Invoice or Check #'s) in Query 2
Creating invoices 1
Incrementing Invoice Number 20
Outlook Creating an Outlook form 2
Auto number in an existing table 4
Query Problem 2
Problem with Query 1

Top