PC Review


Reply
Thread Tools Rate Thread

Confirmation Dialog

 
 
arnold
Guest
Posts: n/a
 
      27th Mar 2007
I have a macro in Access that I want to run when someone clicks a
command button. The code is as follows:

Private Sub Terminate_Click()
On Error GoTo Err_Terminate_Click

Dim stDocName As String

stDocName = "Terminate"
DoCmd.RunMacro stDocName

Exit_Terminate_Click:
Exit Sub

Err_Terminate_Click:
MsgBox Err.Description
Resume Exit_Terminate_Click

End Sub

I would like to add a confirmation dialog box to confirm that the user
wants to terminate the record. How do I add that to the code to make
it work? If they click "no" I want it to return to the record. If
they click "yes" I want to it run the macro. Any help would be
appreciated!

 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      27th Mar 2007
You could try something like this:

If MsgBox("Terminate?", vbOkCancel) = vbOk Then
DoCmd.RunMacro stDocName
End If

But there are numerous other issues that could affect the number of
confirmation dialogs the user would have to deal with here.

If this button is to delete the record, you could try something like this:

If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"arnold" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a macro in Access that I want to run when someone clicks a
> command button. The code is as follows:
>
> Private Sub Terminate_Click()
> On Error GoTo Err_Terminate_Click
>
> Dim stDocName As String
>
> stDocName = "Terminate"
> DoCmd.RunMacro stDocName
>
> Exit_Terminate_Click:
> Exit Sub
>
> Err_Terminate_Click:
> MsgBox Err.Description
> Resume Exit_Terminate_Click
>
> End Sub
>
> I would like to add a confirmation dialog box to confirm that the user
> wants to terminate the record. How do I add that to the code to make
> it work? If they click "no" I want it to return to the record. If
> they click "yes" I want to it run the macro. Any help would be
> appreciated!


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook confirmation dialog. vovan Microsoft Outlook Program Addins 3 22nd Jan 2009 02:51 AM
WM5 Confirmation Dialog ManniAT Microsoft Dot NET Compact Framework 0 8th Aug 2006 11:39 AM
How to pop up a confirmation dialog box? Amelyan Microsoft ASP .NET 1 29th Apr 2005 12:05 AM
C#, Confirmation Dialog box Mathieu Chavoutier Microsoft Dot NET 2 26th Apr 2004 02:45 PM
Dialog Box Confirmation Selection Annie Microsoft Excel Programming 1 24th Aug 2003 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 AM.