Running code with Msgbox

Talismanic

Registered User.
Local time
Today, 20:53
Joined
May 25, 2000
Messages
377
How do I get the vbOK and vbCancel into this msgbox so that my code will run as the user wants. I think all that I have to do is add vbOK and vbCancel to the message box but I can't figure out where and help was no help other then alerting me to the fact that Access has a vbYesNo that would of allowed me to do this with one vb constant instead of two.

Dim intQuestion As Integer

intQuestion = MsgBox("Have you updated the database?" & vbCrLf & _
"Press OK to update or Cancel to close", vbQuestion, _
"Update Check")

If intQuestion = vbOK Then

DoCmd.TransferDatabase acExport, "Microsoft Access", _
"M:\Estimate Tracking\Estimate Tracking.mdb", _
acTable, "EstimateTracking", "TCUpdates", False

Else

Exit Sub

End If

[This message has been edited by Talismanic (edited 02-08-2001).]
 
If I'm understanding your question correctly, all you need to do is use vbOkCancel instead of vbQuestion:

intQuestion = MsgBox("Have you updated the database?" & vbCrLf & _
"Press OK to update or Cancel to close", vbOkCancel, _
"Update Check")

then you can either use:
if intquestion =vbOk then
...
endif
if intquestion =vbCancel then
...
endif

but it would probably be more efficient to use Select/Case instead of If/Then

HTH

Mike

Mike
 
If MsgBox("Have you updated the database? ", vbInformation + vbYesNo, "database update reminder") = vbYes Then
DoCmd.TransferDatabase acExport, "Microsoft Access", _
"M:\Estimate Tracking\Estimate Tracking.mdb", _
acTable, "EstimateTracking", "TCUpdates", False

End If
 

Users who are viewing this thread

Back
Top Bottom