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

MsgBox 2

Status
Not open for further replies.

ddmtn546

Technical User
Dec 20, 2000
38
US
I am trying to make a MsgBox popup when a button is pushed on a form (storm Frm) that prompts for a "yes" or "no" response from an operator before running an update query (UpdateDisp Qry) to a table (storm Tbl). I have used the standard MsgBox feature to run the query, however it only prompts for a "OK" response with no other way to escape without running the query if the operator changes his mind. Any practical examples would be much appreciated in advance.
 
Can you show the code you use to call the message box? I know there is an option to set it for Yes\No and you should be able to either run or not run based on that...

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
try something like this

sMsgReply = MsgBox("message", vbYesNo, "title")


You can then check sMsgReply for vbYes or vbNo through a Switch or IIF construct.



Dave
 
The "OnClick" button on the form calls the "UpdateDisp Macro" which runs a MsgBox under the Action Column. All that is requested for in arguements are message, beep, type and title.
 
You may need to change your button's On Click event from the macro name to an Event Procedure that issues the MsgBox, evaluates user response, and invokes the macro as exampled below.

Private Sub yourbuttonname_Click()

Dim sMsgReply As String

sMsgReply = MsgBox("message", vbYesNo, "title")

If sMsgReply = vbYes Then DoCmd.RunMacro ("yourmacroname")

End Sub



You can then remove the MsgBox action from the macro as it is done in the event procedure.


Dave
 
Check the following example. Access has intrisic values to insert with the msgbox function to set any variation of buttons. Check out MsgBox help.

Public Sub ShowMsgBoxSample()

If MsgBox("Select OK to run the queries.", _
vbOKCancel, "Any Title") = vbOK Then

'Insert query here

End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top