Hello,
I'm pretty new to VBA. I have a form with a combo box, in the combo box is a list of other forms you can open. If someone tries to continue without making a selection I have a message box pop up prompting them to make a selection. The problem I'm having is the form closes before the message box pops up, which I don't want to happen. I've tried removing the DoCmd.Close in the code but then the menu doesn't close after a selection is made and that's the only time I want it to close, is after the user has selected a valid field and pressed continue.
Here's a stripped down version of the code.
On Error GoTo Err_Command65_Click
Dim intOKCancel As Integer
Dim strForm As String
If Me.combobox= "-------" Then
strForm = "--------"
ElseIf Me.Me.combobox = "---------" Then
strForm = "------------"
ElseIf Me.Me.combobox = "-------------" Then
strForm = "--------------"
ElseIf Me.Me.combobox = "-------------" Then
strForm = "-----------"
ElseIf Me.Me.combobox = "--------------" Then
strForm = "--------------"
ElseIf Me.Me.combobox = "--------------" Then
strForm = "--------------"
ElseIf Me.Me.combobox = "--------------" Then
strForm = "------------------"
ElseIf Me.Me.combobox = "--------------" Then
strForm = "--------------"
ElseIf Me.Me.combobox = "---------------" Then
strForm = "-------------"
End If
DoCmd.GoToRecord , , acNewRec
DoCmd.Close
DoCmd.OpenForm strForm
Exit_Command65_Click:
Exit Sub
Err_Command65_Click:
intOKCancel = MsgBox("Please Make Selection", vbOKOnly)
Resume Exit_Command65_Click:
I've sat here for nealry 3 hours trying everything and anything I could think of and find from using google. And as I said I'm still learning so I'm absolutely open to any suggestions.