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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Macro RunCode for Modules 1

Status
Not open for further replies.

Telsa

Programmer
Jun 20, 2000
393
US
We have a module that works great when run from Visual Basic for Application but fails when run under a macro with RunCode.&nbsp;&nbsp;We believe it is because the query it calls may have no records.&nbsp;&nbsp;But the module has an escape that if there is no BOF or EOF then ENd. <br><br>Like I said, it works perfectly from the procedural standpoint.&nbsp;&nbsp;I did create a function in the module to simply call the first procedure.&nbsp;&nbsp;I use the function in the macro RunCode.<br><br>But as a macro it fails and gives no hint why.&nbsp;&nbsp;Anyone experienced and resolved this?&nbsp;&nbsp;<br><br>Thanks!<br><br>Mary :eek:)<br><br>
 
First, are you running a Sub or a Function? It has to be a function for the macro to run it with the RunCode command.<br><br>Second, why is a macro required? The only thing that would REQUIRE you to use a macro would be AutoKeys, or AutoExec, and there are ways around the AutoExec.<br><br>Also, I am not positive, but I think if you run code through a macro, it will basically ignore any error trapping you may have. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
I do have the macro attached to a function.&nbsp;&nbsp;This function calls the procedure that starts the whole process.&nbsp;&nbsp;<br><br>How else would I run the procedure in a form say?&nbsp;&nbsp;I thought the only way was to attach its function (the one that calls the procedure) to a macro to run.&nbsp;&nbsp;<br><br>The escape I created is simply an If... THen statement about the BOF and EOF.<br><br>Any ideas?<br><br>Mary :eek:)
 
What initiates the function? Open of Application? Button Click? Open of a form?<br><br>In other words, what starts the macro? Is it a procedure, or is it manual?<br>If it is manual, why can't it be put on a procedure, then you don't need to use a macro. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
We haven't attached the macro to a button yet... but it is our intent.&nbsp;&nbsp;Right now when we run it, we just double click the macro itself which is suppose to run the function that calls the procedure (which flows into a few other procedures).&nbsp;&nbsp;<br><br>Just to let you know, the module/procedures build an html table based on the query.<br><br>Is there a way to attached the procedure itself to the button?&nbsp;&nbsp;I assumed not because the &quot;wizard&quot; doesn't ask for one... it asks for a macro.<br><br>Mary :eek:)<br>
 
Yes, that was my intention. <br><br>Create a button<br>Give it a descriptive name<br>Right click on the button and select &quot;Build Event&quot;<br>Select Code Builder <br><br>You should see the following:<br><br>-----<br>Private Sub YourButtonName_Click()<br><br>End Sub<br>-----<br><br>Now make it look like this:<br><br>-----<br>Private Sub YourButtonName_Click()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call YourFunctionName<br>End Sub<br>-----<br><br>Now when you press the button, it will call the function you have created, and you never need the macro.<br><br>Any questions, e-mail me. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Thank you!&nbsp;&nbsp;It works like a charm!!!<br><br><br>Mary :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top