Macros Won't Run

  • Thread starter Thread starter connellg via AccessMonster.com
  • Start date Start date
C

connellg via AccessMonster.com

This is the VBA code executed from OnClick on a form's command button, to run
4 macros:

Private Sub Command160_Click()
DBEngine(0)(0).Execute "Append to Delivery List Table", dbFailOnError
DBEngine(0)(0).Execute "Print Work Order", dbFailOnError
DBEngine(0)(0).Execute "Print Final Inspection", dbFailOnError
DBEngine(0)(0).Execute "New Record", dbFailOnError
End Sub

An error message states "Compile Error", "Variable Not Defined"

Would appreciate your help in de-bugging this. Thanks.
 
If these are true "Macros", according to Help:

CurrentDB.Execute ()

Runs an action query or executes an SQL statement on a specified Connection
or Database object


If you want to run a "Macro" in VBA code, the syntax is

DoCmd.RunMacro "My Macro"



I do not use macros; they have no error handling and, IMO, are to limiting.
I would suggest converting the macros to code....


To convert global macros to Visual Basic:

1. In the Database window, click Macros under Objects.

2. Click the name of the macro you want to convert.

3. On the File menu, click Save As.

4. In the Save As dialog box, click Module and click OK.

5. In the Convert macro dialog box, select the options you want, and click
Convert.


HTH
 

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

Back
Top