Incrementing Number Field

  • Thread starter Thread starter vb_Dumb
  • Start date Start date
V

vb_Dumb

I am having a tough time with these dmax formulas for some reason it
keeps telling me that my it can't find my table if some one can take a
look at this code and tell me whats wrong or has a new idea i got this
code from here so if anyone can help with this that would be awesome
thanks, Dan

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.DMRnumbertxt = Nz(DMax("DMR_Number", "ETP_Table"), 0) + 1
End If
End Sub

dmrnumbertxt is the name of the field on the form
dmr number is the control source
Etp table is the table dmr number is located

Error message: the Microsoft jet engine could not find the object
'forms'. Make sure the object exists and that you spell its name and
path correctly
 
In your text, you say that the name of the table is Etp table (with a space)
and that the control source is dmr number (with a space), yet in your DMax
statement, you've got underscores. Which is it?

If you do have spaces in your names (which, incidentally, is almost always a
bad idea), use

Me.DMRnumbertxt = Nz(DMax("[DMR Number]", "[ETP Table]"), 0) + 1
 
On Tue, 2 Dec 2008 05:18:22 -0800 (PST), vb_Dumb <[email protected]>
wrote:

That's not a very helpful error message. Try this first in the
Immediate window while you are at a breakpoint in your form:
?DMax("DMR_Number", "ETP_Table")
It should return a number. Does it? If not, what is the error you are
getting?

-Tom.
Microsoft Access MVP
 
That's not a very helpful error message. Try this first in the
Immediate window while you are at a breakpoint in your form:
?DMax("DMR_Number", "ETP_Table")
It should return a number. Does it? If not, what is the error you are
getting?

-Tom.
Microsoft Access MVP

ok doug your right i should have spaces instead of an underscore but i
fixed that and now i am getting an error message saying Runtime error
3075 syntax error missing operator in query expression 'Max(dmr
number)" any help?
Thank for the responses, Dan
 
Your error message says Max, not DMax.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


That's not a very helpful error message. Try this first in the
Immediate window while you are at a breakpoint in your form:
?DMax("DMR_Number", "ETP_Table")
It should return a number. Does it? If not, what is the error you are
getting?

-Tom.
Microsoft Access MVP

ok doug your right i should have spaces instead of an underscore but i
fixed that and now i am getting an error message saying Runtime error
3075 syntax error missing operator in query expression 'Max(dmr
number)" any help?
Thank for the responses, Dan
 
Back
Top