Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prompt messages

Status
Not open for further replies.
Sep 16, 2004
21
0
0
GB
i have a button on a form which when clicked runs a macro. But i want to add a prompt msg when the button is clicked, which states "do you wish to run the macro". When they click ok they will run the macro otherwise if they select cancel then they just go back to the form

thanks
 
If MsgBox("Really do this",vbyesno,"Warning") = vbYes Then
' do whatever
else
' do the other
end if

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
im not too sure what to change, he is the VB code at the moment
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click

Dim stDocName As String

stDocName = "close all"
DoCmd.RunMacro stDocName

Exit_Command39_Click:
Exit Sub

Err_Command39_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command39_Click

End Sub

// with close all the name of the macro. where do i need to make the changes for the prompt msg
 
How are ya donnie051280 . . . . .

Try this:
Code:
[blue]Private Sub Command39_Click()
Dim Msg As String, Style As Integer
Dim Title As String, DL As String

On Error GoTo Err_Command39_Click

   Dim stDocName As String
   DL = vbNewLine & vbNewLine
   
   Msg = "Are you sure you want to run the Macro ?" & DL & _
         "Click 'Yes' to run the Macro . . ." & DL & _
         "Click 'No' to abort!"
   Style = vbInformation + vbYesNo
   Title = "Run Macro Confirmation! . . . . ."
   
   If MsgBox(Msg, Style, Title) = vbYes Then
      stDocName = "close all"
      DoCmd.RunMacro stDocName
   End If

Exit_Command39_Click:
   Exit Sub

Err_Command39_Click:
   MsgBox Err.Description
   Resume Exit_Command39_Click
    
End Sub[/blue]
Be aware: [blue]VBA[/blue] can run the [blue]equivalent[/blue] of any macro, and much faster.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top