Calling macro from vb

  • Thread starter Thread starter kap
  • Start date Start date
K

kap

I'm just starting to learn about visual basic so I wrote
this simple subroutine which is attached to a button on a
form and activated on Click:

Sub QuickMessage()
DoCmd.RunMacro "NJ_TestMessage"
End Sub

The macro simply displays an information message box. The
problem is that I have to click the "OK" button three
times in the message box to close the message box. Can
anyone explain why?
 
Try taking the Macro out of the equation all together.

Sub QuickMessage()
MsgBox "Your Custom Message Here"
End Sub

The the click event for your button would look like this:

Sub YourButton_Click
QuickMessage
End Sub
 
Ahah! Ignore my other reply. I was calling the subroutine
by name from the button On Click property. After I got the
subroutine assigned to just the button object your code
works just fine. Thanks.
 
Back
Top