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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox on top of userform 1

Status
Not open for further replies.

mleosu

Technical User
Sep 26, 2006
56
US
I have a userform with rules set up in the code to check to see if when certain options are selected, then to check to make sure that text was entered in the textboxes.

the validation runs fine and my msgbox appears (through a macro that the userform code calls) but when you click ok in the msg box, the msgbox and the form closes.

i want it to go back to the form (preferably where it was when we left it for the msgbox).

here are the codes:
FOR THE USERFORM:
Code:
Private Sub OKButton_Click()



Application.ScreenUpdating = False
'exit if a range is not selected
If TypeName(Selection) <> "Range" Then Exit Sub


'marks iInfo as active request
If II Then
ActiveSheet.Cells(ActiveCell.Row, 6).Select
ActiveCell.Value = "X"
ElseIf Not II Then
ActiveSheet.Cells(ActiveCell.Row, 6).Select
ActiveCell.Value = ""
End If

'marks Webrecon as active request
If WR Then
ActiveSheet.Cells(ActiveCell.Row, 7).Select
ActiveCell.Value = "X"
ElseIf Not WR Then
ActiveSheet.Cells(ActiveCell.Row, 7).Select
ActiveCell.Value = ""
End If

'shows message box if acct and loc are empty
If SM Or SL Or ML Then errormsg

Unload WebOrderRole

End Sub

FOR THE MSGBOX:
Code:
Sub errormsg()
'gives error message if account and location feilds are empty
If ActiveSheet.Cells(ActiveCell.Row, 10).Value = "" And ActiveSheet.Cells(ActiveCell.Row, 11).Value = "" Then
ans = MsgBox("Account and Location numbers must be provided!", vbCritical + vbOKOnly)
End If

End Sub

any help is greatly appreciated. thanks!
 
...
If SM Or SL Or ML Then
errormsg
Else
Unload WebOrderRole
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
that works, but now when it goes back to the userform to enter the data, i click the okay button and nothing. the userform does not close.

so i put unload weborderrole after the end if again and it went back to the original problem

 
Where are populated SM, SL and ML ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
SM, SL and ML are populated in the userform under WO.

code for WO:
Code:
Private Sub WO_Click()

If WO And Sheet1.CheckBox1 Then
'disables everything except BG and RBG due to bank employee
SM.Enabled = False
SL.Enabled = False
ML.Enabled = False
BG.Enabled = True
RBG.Enabled = True
'marks WebOrder as active request
ActiveSheet.Cells(ActiveCell.Row, 8).Select
ActiveCell.Value = "X"

ElseIf WO Then
'enables ALL weborder options
SM.Enabled = True
SL.Enabled = True
ML.Enabled = True
BG.Enabled = True
RBG.Enabled = True
'marks WebOrder as active request
ActiveSheet.Cells(ActiveCell.Row, 8).Select
ActiveCell.Value = "X"

ElseIf Not WO Then
ActiveSheet.Cells(ActiveCell.Row, 8).Select
ActiveCell.Value = ""
SM.Enabled = False
SL.Enabled = False
ML.Enabled = False
BG.Enabled = False
RBG.Enabled = False
End If
End Sub

code for SM
(same for SL and ML, except SM is replaced with SL and ML)

Code:
Private Sub SM_Click()
ActiveSheet.Cells(ActiveCell.Row, 9).Select
ActiveCell.Value = "SM"
acct.Enabled = True
loc.Enabled = True
Frame1.Enabled = True
Label4.Enabled = True
End Sub
 
...
If (SM Or SL Or ML) _
And ActiveSheet.Cells(ActiveCell.Row, 10).Value = "" _
And ActiveSheet.Cells(ActiveCell.Row, 11).Value = "" Then
errormsg
Else
Unload WebOrderRole
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top