Calling macro from vb

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?
 
L

Lynn Trapp

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
 
K

kap

Nope, still does the same thing. The subprocedure is
looping three times, not the macro.
 
K

kap

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.
 

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

Top