MsgBox

dadrew

Registered User.
Local time
Today, 09:19
Joined
Sep 15, 2003
Messages
186
Having a small problem with amessage box. I have a combo box and a button which takes you to another form. When the user clicks on the button I want a message box to appear if the Combo box value is null. This is code im using but its not working correctly, something simple I hope!

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click
If Me.Combo5 = Null Then
MsgBox "Please select an exercise from the list."
Me.Visible = False
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Armour_Selection"

stLinkCriteria = "[Exercise_Name]=" & "'" & Me![Combo5] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command13_Click:
Exit Sub
DoCmd.Close

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub
 
OK thats better. I now get the message box, but when I click OK on the message box my new form opens. I need to force the user to make a selection from the Combo box.
 
Code:
 If IsNull(Me.Combo5) Then
      MsgBox "Please select an exercise from the list."
      DoCmd.CancelEvent
 Else
      Me.Visible = False
      Dim stDocName As String
      Dim stLinkCriteria As String
      stDocName = "Armour_Selection"

      stLinkCriteria = "[Exercise_Name]=" & "'" & Me![Combo5] & "'"
      DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
 
Last edited:
Thanks, Else was the msssing word. Told you it was an easy one!
 

Users who are viewing this thread

Back
Top Bottom