I have a form that is for estimates. When I open the form I wish it to automatically assign the next available number to that form. For example if I am inputting my 10th estimate I want the form to say Estimate #10. How can I do this?
I have a form that is for estimates. When I open the form I wish it to automatically assign the next available number to that form. For example if I am inputting my 10th estimate I want the form to say Estimate #10. How can I do this?
You need to store this value in table then use code to look for the max value and increment. This is like creating a custom unique ID. Are there multiple users of this database?
Tenth estimate in relation to what - single customer, single product, each sales person, that day or week or month or year, the entire database?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Single user, 10th estimate of entire database. Can you help with the code?
Never mind I finally got it figured out. Thanks anyway
Would you like to share the solution?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I added a field named Invoice to the form's table, type number and long integer.
Then I set the control source to that field, and set Devault Value to =GetNextInvoice.
Then I created:
Public Function GetNextInvoice()
'get next free invoice number
GetNextInvoice=Nz(DMax("[Invoice]","[tblname")+1,1)
End Function
I also had to put the number 1 in the table so it had a number to start from.