Creating a Prompt

  • Thread starter Thread starter kateri4482
  • Start date Start date
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!
 
If MsgBox("Are You Sure?", vbYesNo + vbQuestion) = vbYes Then
' put code to run queries here

End If
 
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
 
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top