If statement

A

Alex Martinez

Hello,

I am having a problem with my ElseIf statement which is in my form event
(Before update) I have two fields one call AssignedOn, which is a date field
and the other is AssignedTo a text field. My problem is I get a error
message -Run time error "424" Object Required using the below code. What I
want is when the user populate the AssignedTo field (User Name) and forgets
to put a date on the AssignedOn date field I want an error message pop up.
This is the last piece of code that I have in my If statement, but I can't
figure it out. I would appreciate any tips. Thank you.


ElseIf Me.[AssignedOn] Is Null And Me.[AssignedTo] Is Not Null Then
Cancel = True
MsgBox "Sorry, You must assigned this policy to a user. Try Again"


End If
 
F

FSt1

hi,
i may be wrong but looks like it might be a syntax thing.
Is null should be 1 word ie IsNull. and Is Not Null should be Not IsNull
if that do work then you might look into error handling.
at the top of you sub put something like ....
On Error goto MySub_err
then at the bottom of the sub put some like
mySub_Exit:
Exit sub

MySub_Err:
If Err.number = 424 then
Msgbox("Sorry, You must assigned this policy to a user. Try Again")
Resume Mysub_Exit
end if
end sub

good luck
FSt1
 

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

Top