Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still can't get message box function to work-HIGHLY EMBARASSED

Status
Not open for further replies.

Kallen

MIS
Aug 14, 2001
80
US
Hi everyone.

I have posted this question a couple of times, and many of you gave me some helpful info, but I am still getting the error "previous operation cancelled" after my customized message box (I don't want the oper. cancelled msgbox to appear). This is what I have so far.

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 required"
DoCmd.SetWarnings False
DoCmd.CancelEvent
DoCmd.SetWarnings True
exit for
end if
end if
next
end sub

I am now starting to wonder if I should be going to all of the required fields on the form itself and individually put in my msgBox code in the before update section of each textbox. Someone told me that the above route was the best way to go.

This is really embarassing because I have done research over the internet, helpfiles, bulletin boards and books, and can't see what I am doing wrong. I feel as though I have lost my mind!!

As always, any suggestions would be much appreciated
 
Kallen,

I have just copied and pasted your code and it worked fine. Have u tried stepping thro it?

Nick
 
how about adding in

Code:
On Error Resume Next

at the beginning of your code?
 
Yes, I did try stepping into it. It works fine until my first message box (the one the I want) executes. After that I get the other message box, that I do not want. I will try your suggestion "on error resume next".

Maybe I should delete my code and start from scratch.

I am wondering if it has anything to do with the fact that I have it tagged as required at the table level.

My database is at home, so I will try it again and let you know.

Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top