What does this mean

rgreene

Registered User.
Local time
Today, 04:55
Joined
Jan 22, 2002
Messages
168
What I'm trying to do is if the ID field is blank the do the DMAX command If ID isn't blank then display the msgbox.

I get

Run-Time error '424'
object required

Here is my code:

Private Sub AssignID_Click()

If Me.ID Is Null Then
Me.ID = DMax("ID", "tblResidents") + 1
End If

If Not Me.ID Then
MsgBox ("Resident already has an ID")
End If

End Sub

Thanks,
Rick
 
Try this:

Code:
 Me.ID = DMax("[ID]", "tblResidents") + 1

DMax (and all other domain aggregates) require a field name as argument one, but further demand that it be in brackets. But they do not require brackets for the domain named in argument two. Go figure.
 
I had just the DMAX statement and it worked fine. I tried adding the IF THEN stuff and now I get the error. Ionly want my DMAX statment to run if the ID field is blank. If there already is a ID I don't want it replaced.

Sorry about the reply post Doc_Man I noticed my mistake and I thought I deleted it but I guess I didn't. I have now.
 
Try:
If IsNull (Me.ID) Then
Me.ID = DMax("ID", "tblResidents") + 1
Else
MsgBox ("Resident already has an ID")
End If

Michael
 

Users who are viewing this thread

Back
Top Bottom