MsgBox execution sends program into design mode

J

Jenn

Hello

This is my code:
'Checks to see if work order # was entered correctly in textbox1, if not it gives error message and sends
'user back to textbox1

WOVar = MainForm.TextBox1.Valu
Response2 = (WOVar Like "####"

Do While Response2 = Fals

promptvar = "The Work Order # was typed incorrectly, please retype, Example: 4160
CheckVar = MsgBox(promptvar, vbCritical + vbOKOnly, "Continue"
If CheckVar = 1 Then MainForm.TextBox1.SetFocu
En
Response2 = (WOVar Like "####"

Loo

This is executed from a module, public sub, mainform is the userform where textbox1 is. When this code is executed the message box works correctly, but when you hit ok the program does not continue, instead it pops out of "run" mode into "design" mode. This is data validation code which i need, I have very similar code running in the userform sub, so I am assuming it has something to with being a called procedure running from a module? Any help would be greatly appreciated, thanks

Jennifer
 
J

Juan Pablo González

Jenn said:
Hello,

This is executed from a module, public sub, mainform is the userform
where textbox1 is. When this code is executed the message box works
correctly, but when you hit ok the program does not continue, instead
it pops out of "run" mode into "design" mode. This is data validation
code which i need, I have very similar code running in the userform
sub, so I am assuming it has something to with being a called
procedure running from a module? Any help would be greatly
appreciated, thanks.

Jennifer

The use of 'End' is a bit drastic. Try using 'Exit Sub' instead to see if
that works better.
 
J

Jenn

Juan

Thanks, but I need the End for the If then statement. Also, I don't want to exit the sub at that particular spot. Any other ideas

Jenn
 
Top