I am having problems with my MsgBox code. I wanted the vbOKCancel button but then changed to vbOK. It still shows vbOKCancel but when I click either button, neither one works. When click OK continue running report; Cancel = back to form. This is what I have so far. I inserted the Msg coding in the middle of my click event. That's probably one problem. I tried assigning a DoCmd.OpenReport to my "else" statement, but that didn't work either. Help! I'm very new to VB so I'm sorry to ask if you would be very specific when explaining.
Private Sub TM_5digitZip_Click()
On Error GoTo Err_TM_5digitZip_Click
Dim Msg, Style, Title, Ctxt, Response, MyString
Msg = "Did you Export or Print report before Assigning TM ?" ' Define message.
Style = vbOK + vbExclamation ' Define buttons.
Title = "Warning" ' Define title.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then ' User chose OK.
MyString = "OK" ' Perform some action.
Else ' User chose Cancel.
MyString = "Cancel"
End If
Dim stDocName As String
stDocName = "qupdAssignTM_by5digitZip"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_TM_5digitZip_Click:
Exit Sub
Err_TM_5digitZip_Click:
MsgBox Err.Description
Resume Exit_TM_5digitZip_Click
End Sub
dmposey61
Private Sub TM_5digitZip_Click()
On Error GoTo Err_TM_5digitZip_Click
Dim Msg, Style, Title, Ctxt, Response, MyString
Msg = "Did you Export or Print report before Assigning TM ?" ' Define message.
Style = vbOK + vbExclamation ' Define buttons.
Title = "Warning" ' Define title.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then ' User chose OK.
MyString = "OK" ' Perform some action.
Else ' User chose Cancel.
MyString = "Cancel"
End If
Dim stDocName As String
stDocName = "qupdAssignTM_by5digitZip"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_TM_5digitZip_Click:
Exit Sub
Err_TM_5digitZip_Click:
MsgBox Err.Description
Resume Exit_TM_5digitZip_Click
End Sub
dmposey61