Name#? error driving me crazy

  • Thread starter Thread starter John Egan
  • Start date Start date
J

John Egan

I have a form, "JobCardForm" to enter data into a table "JobCard". I want to
automatically increment the "JobNumber" field in this table. I thought I
could just put a function in the default value of the form control for
JobNumber.
I have entered =DMax(["JobNumber"],["JobCard"])+1 into the default value
field in the control box for JobNumber in the JobCardForm. When I go bact to
use the form and try to enter a new record I get the Name#? error in the box
for JobNumber. Any help please.

John
 
I have a form, "JobCardForm" to enter data into a table "JobCard". I want to
automatically increment the "JobNumber" field in this table. I thought I
could just put a function in the default value of the form control for
JobNumber.
I have entered =DMax(["JobNumber"],["JobCard"])+1 into the default value
field in the control box for JobNumber in the JobCardForm. When I go bact to
use the form and try to enter a new record I get the Name#? error in the box
for JobNumber. Any help please.

John

You've got your quotes and your brackets inside out for one thing!

Instead of using the default value, I'd suggest using the Form's
BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!JobNumber = NZ(DMax("[JobNumber]", "[JobCard]")) + 1
End Sub
 

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

How to get data out of database suggestions? 4
Select query in form 3
Custom ID Field 4
Insert Command 1
relationship 2
Dmax Problem 5
Enter Parameter Values Problem 1
Where clause with 2 criteria 6

Back
Top