Createing Yes No Msg boxes.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know how to create msg boxes using macros. However they dont give the
options of asking Are you sure? Yes - Carrys on with Macro, no ends macro and
reads action cancelled.

Best example is are you sure you want to delete this record? [Yes] - Record
Deleted (Takes me back to a set location) [No] Deletion cancelled - (Ends
macro.)

Any suggestions? I am sure i will need to write in Vb but unsure of what to
do/type.

Any help greatly appreciated.
 
You can use MsgBox() in Condition column of the macro, e.g.:
MsgBox("Sure?",4) = 6
and the action will only execute if the person answers Yes.
To execute the next line on the same condition, enter:
...
The StopMacro and StopAllMacros action are also useful.

Realistically, though, you do need to move to VBA to get the serious power
of branches and loops, not to mention error-handling.

To get started:
1. Create a command button.

2. Set its On Click property to:
[Event Procedure]

3. Click the Build button (...) beside this.
Access opens the code window

4. Between the "Private Sub..." and "End Sub lines, enter:
If MsgBox("Sure?", vbYesNo) = vbYes Then
Debug.Print "You answered Yes"
Else
Debug.Print "You answered No."
End If

5. Run the code (by clicking the button).
Press Ctrl+G to open the Immediate window, and see what comes out.
 
thxs for replying. Ill let you know the results.

Regards

Allen Browne said:
You can use MsgBox() in Condition column of the macro, e.g.:
MsgBox("Sure?",4) = 6
and the action will only execute if the person answers Yes.
To execute the next line on the same condition, enter:
...
The StopMacro and StopAllMacros action are also useful.

Realistically, though, you do need to move to VBA to get the serious power
of branches and loops, not to mention error-handling.

To get started:
1. Create a command button.

2. Set its On Click property to:
[Event Procedure]

3. Click the Build button (...) beside this.
Access opens the code window

4. Between the "Private Sub..." and "End Sub lines, enter:
If MsgBox("Sure?", vbYesNo) = vbYes Then
Debug.Print "You answered Yes"
Else
Debug.Print "You answered No."
End If

5. Run the code (by clicking the button).
Press Ctrl+G to open the Immediate window, and see what comes out.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Access to Access said:
I know how to create msg boxes using macros. However they dont give the
options of asking Are you sure? Yes - Carrys on with Macro, no ends macro
and
reads action cancelled.

Best example is are you sure you want to delete this record? [Yes] -
Record
Deleted (Takes me back to a set location) [No] Deletion cancelled - (Ends
macro.)

Any suggestions? I am sure i will need to write in Vb but unsure of what
to
do/type.

Any help greatly appreciated.
 

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