numbering in Access

J

J Bower

in 2003 if I had a field I used for invoices and I began by number the first
few it would continue to do that for me automatically. This feature does not
seem to work on 2007? Is there a way I can make this work? Could anyone
suggest if a macro could be written for this? If so could you provide an
example of this?
 
K

Ken Sheridan

In a single user environment you can insert the next number into the invoice
number control on a form with code in the BeforeInsert event procedure of the
form which looks up the highest existing number and adds 1, e.g.

Me.InvoiceNumber = DMax("InvoiceNumber","Invoices") + 1

Where InvoiceNumber is the name of the field and Invoices the name of the
table.


In a multi-user environment on a network conflicts could arise if two or
more users are adding a record simultaneously. There are various solutions
to this, one of which you'll find at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=23839&webtag=ws-msdevapps


which also allows for the number at which the sequence begins when the next
record is added to be reset.

Ken Sheridan
Stafford, England
 
J

J Bower

That makes sense. Is the script you have listed below a macro or where do I
make the changes?
 
K

Ken Sheridan

Its an event procedure not a macro. To insert the code open the form in
design view, and open the form's properties sheet. On the Events tab select
the Before Update event property and click on the 'build' button (the one
with three dots to the right). Select Code Builder and then when the VBA
window opens enter the line of code as a new line in the event procedure
between the two already in place.

Remember that when referring to object names such as table or field names,
if they contain spaces or other special characters, you wrap the name in
brackets [like this].

Ken Sheridan
Stafford, England
 
J

J Bower

Thank you for your help.

Ken Sheridan said:
Its an event procedure not a macro. To insert the code open the form in
design view, and open the form's properties sheet. On the Events tab select
the Before Update event property and click on the 'build' button (the one
with three dots to the right). Select Code Builder and then when the VBA
window opens enter the line of code as a new line in the event procedure
between the two already in place.

Remember that when referring to object names such as table or field names,
if they contain spaces or other special characters, you wrap the name in
brackets [like this].

Ken Sheridan
Stafford, England

J Bower said:
That makes sense. Is the script you have listed below a macro or where do I
make the changes?
 
Top