Best to do this in the BeforeUpdate event of the form. That's the last
possible moment you can assign the number before the record is saved. This
timing reduces the chance that 2 users who are both entering data will be
assigned the same number.
Set the BeforeUpdate property of the form (not that of a control) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, enter:
Me.[InvoiceID] = Nz(DMax("InvoiceID", "tblInvoice"), 0) + 1
Replace InvoiceID with the name of your number field, and tblInvoice with
the name of your table.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.htmlReference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9862
Reply to group, rather than allenbrowne at mvps dot org.
"danh"
wrote in message
news:764EB741-DAA0-427E-ACE2-04F2C0367C7B@microsoft.com...
> When I create a new invoice I would like the new no. to come on my form
> automatically. It reads the last InvNo and adds 1 to it and displays it
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9862
> on
> the screen. Can somebody help me do this?
> Thanks
> Dan