prefill a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to create a form for data entry purposes. I have a numeric field
in the database called invoice_ID. I would like to pre-fill the Invoice_Id
field in the form with the highest invoice_ID in the database + 1. I have a
query defined (Max_ID) that selects the max id (as ID) already in the
database. When designing the form, I enter "=[Max_ID]![ID]+1" as the default
in the properties window for the field linked to Invoice_ID. This results in
an error and I can't figure out why. Any help would be greatly appreciated.
 
You can't have done much of a search for an answer. This question has only
been answered 3 or 4 times in the last week, but here it is again:

=Nz(DMax("[invoice_ID]","InvoiceTableNameGoesHere"),0)+1

Be aware that if you are in a multi-user environment and more than one user
may be adding invoices at the same time, it is possible both could get the
same new invoice number and create a conflict. It would be wise to check in
the Form's Before Update event to be sure the number is still available and
take whatever action you want if another user has already updated the table
with the new invoice number.

If Not IsNull(DLookup("[invoice_ID]","InvoiceTableNameGoesHere", _
"[invoice_ID] = '" & Me.txtInvoiceID & "'")) Then
MsgBox "Invoice ID " & Me.txtInvoiceID & " is in use"
'Do what needs to be done here
End If
 

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

Back
Top