Creating a Prompt

K

kateri4482

I have a command button that runs an end of month process using two queries,
and before these queries run, I would like to prompt the user with something
like "Are you sure?" and then give them the option of clicking Yes or No.
This way they won't click this button by mistake and run the process when it
isn't time. How exactly do I write this prompt? Thanks!
 
D

Douglas J. Steele

If MsgBox("Are You Sure?", vbYesNo + vbQuestion) = vbYes Then
' put code to run queries here

End If
 
G

Gina Whipp

An oldie but a goodie...

Dim Msg, Style, Title, Response, MyString

Msg = "Are you sure?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Confirm..."

Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then
MyString = "Yes"
DoCmd.SetWarnings False
DoCmd.RunSQL OR DoCmd.OpenQuery Type Your Query Name
DoCmd.SetWarnings True
Else
MyString = "No"
DoCmd.CancelEvent
End If
 
R

Rob Parker

If MsgBox("Are you sure?", vbYesNo) = vbYes Then
'your existing code here
End If
 
L

Larry Linson

<GRIN> Are you sure you want to ask "are you sure"? More often than being
helpful, such a question is just an irritant. Would it make the user any
safer if you then asked "Are you sure you are sure?" -- I'd guess it would
not.

It's better to document thoroughly with labels on your forms, in most cases;
it's always better to design so that accidentally running something at the
wrong time does not do permanent damage to your data!

Larry Linson
Microsoft Office Access MVP
 
Top