Hi Everyone,
I have a form that is used to add new information that is required. There are 4 fields that are required, and I have them tagged as required. I have the following code on before update of the form itself.
Dim ctl as control
for each ctl in controls
if ctl.tag = "Required" then
if IsNull(ctl.value) then
msgBox ctl.name & " is a required field"
DoCmd=Cancel Event
exit for
end if
end if
next
end sub
This seems to be working fine w/ one exception. What I get after the message box that I want to appear, is another message box that I did not create that says "the previous operation was cancelled". Does anyone know what is wrong w/ my code to make this happen?
FYI: This is based on a query, so I don't think making it required at the table level will help me (I tried & it did not work)
Thanks, and I hope all of you have a good weekend.
I have a form that is used to add new information that is required. There are 4 fields that are required, and I have them tagged as required. I have the following code on before update of the form itself.
Dim ctl as control
for each ctl in controls
if ctl.tag = "Required" then
if IsNull(ctl.value) then
msgBox ctl.name & " is a required field"
DoCmd=Cancel Event
exit for
end if
end if
next
end sub
This seems to be working fine w/ one exception. What I get after the message box that I want to appear, is another message box that I did not create that says "the previous operation was cancelled". Does anyone know what is wrong w/ my code to make this happen?
FYI: This is based on a query, so I don't think making it required at the table level will help me (I tried & it did not work)
Thanks, and I hope all of you have a good weekend.