Natalie50208
New Member
- Joined
- Jul 17, 2007
- Messages
- 42
I'm working on a userform (my first) and have managed to stump myself on the following:
I have several fields that are 'required'. If a required field is not completed, a message box is prompted when the user clicks a button to create an excel form. I think I have that piece...so far so good....
My issue is that if the message box is prompted, I want to exit the script (the remaining code loads the excel sheet and clears the user form [I don't want the user to have to start from scratch if they forget a field]).
Here's the code that I have to prompt the message box:
Select Case True
Case Revenue_Entry.txtDate.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtRqstr.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtProCtr.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtProCtrNm.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboME.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboPostClose.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboEntry.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboAutoRev.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
End Select
I've tried inserting the following throughout, but it didn't stop the script when the message boxes were prompted:
If MsgBox("Please Complete All General Information") = True Then
Exit Sub
End If
Any advice will be greatly appreciated
I have several fields that are 'required'. If a required field is not completed, a message box is prompted when the user clicks a button to create an excel form. I think I have that piece...so far so good....
My issue is that if the message box is prompted, I want to exit the script (the remaining code loads the excel sheet and clears the user form [I don't want the user to have to start from scratch if they forget a field]).
Here's the code that I have to prompt the message box:
Select Case True
Case Revenue_Entry.txtDate.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtRqstr.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtProCtr.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.txtProCtrNm.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboME.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboPostClose.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboEntry.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
Case Revenue_Entry.cboAutoRev.Value = ""
MsgBox "Please Complete All General Information"
Cancel = True
End Select
I've tried inserting the following throughout, but it didn't stop the script when the message boxes were prompted:
If MsgBox("Please Complete All General Information") = True Then
Exit Sub
End If
Any advice will be greatly appreciated