Confirmation on a command button

Q

QC

I am running a command button which runs a query and I want to have a box
come up to have confirmation that I want to continue running the query. So
when I click on the button I want a YES/NO button to confirm that I want to
continue.

Thanks
 
S

Shane

Add this in your VB code (and change names where appropriate). This code will
prompt a user to see if he wants to run the query. If you select Yes, it
opens the query. If no, then it just displays the message "Query Cancelled":

Sub Button_Name_Click()
Dim result As Integer

result = MsgBox("Run Query", vbYesNo)

If (result = vbYes) Then
DoCmd.OpenQuery "Query"
Else
MsgBox "Query Cancelled"
End If
End Sub

Now, if you meant that you want to run a query first and then in the middle
of it, prompt the user to continue, then you're on your own, because there's
no way to do that that I am aware of.

-Shane
 
Top