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

MsgBox problem 1

Status
Not open for further replies.

dmposey61

Technical User
Mar 26, 2004
11
US
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
 
To have only the OK button, try this:
Style = [highlight]vbOKOnly[/highlight] + vbExclamation
To have both the OK and Cancel buttons, try this:
Style = [highlight]vbOKCancel[/highlight] + vbExclamation

Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then ' User chose OK.
Dim stDocName As String
stDocName = "qupdAssignTM_by5digitZip"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else ' User chose Cancel.
MsgBox "Cancel"
End If




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

Part and Inventory Search

Sponsor

Back
Top