473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

running a macro

3
I created a macro (OpenAllrpts) that opens 7 reports. In the argument section I have listed the name of the report and Print preview.
In the code behind the form the user will use I have docmd.runmacro OpenAllrpts. I'm getting an error that an argument is needed. What do I do?
Nov 16 '06 #1
3 4827
Tanis
143 100+
Can you post the maco. Incidentally, I would try to steer clear of macros. Use VBA instead, much more flexible. For instance, would you always want to run the seven reports together, or anyone of the on their own?
Nov 16 '06 #2
I created a macro (OpenAllrpts) that opens 7 reports. In the argument section I have listed the name of the report and Print preview.
In the code behind the form the user will use I have docmd.runmacro OpenAllrpts. I'm getting an error that an argument is needed. What do I do?
I think you need to quote the name of the macro, so you would have

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunMacro "OpenAllrpts"
If you don't do that, the "MacroName" argument (not optional) will not be present, thus returning the error you see.

By the way, are you using the "Option.Explicit" statement at the beginning of the VBA module behind your form? It's always a good idea to have that one, and do a Compilation (Menu "Debug", item "Compile") before trying to run your code.

Just my 2 cents.
Nov 16 '06 #3
PEB
1,418 Expert 1GB
Maybe the VB help will be usefull:

VBA Help
RunMacro Method
RunMacro Method
See Also Applies To Example Specifics
The RunMacro method carries out the RunMacro action in Visual Basic.

expression.RunMacro(MacroName, RepeatCount, RepeatExpression)

expression Required. An expression that returns one of the objects in the Applies To list.

MacroName Required Variant. A string expression that's the valid name of a macro in the current database. If you run Visual Basic code containing the RunMacro method in a library database, Microsoft Access looks for the macro with this name in the library database and doesn't look for it in the current database.

RepeatCount Optional Variant. A numeric expression that evaluates to an integer, which is the number of times the macro will run.

RepeatExpression Optional Variant. A numeric expression that's evaluated each time the macro runs. When it evaluates to False (0), the macro stops running.


Remarks
For more information on how the action and its arguments work, see the action topic.

You can use macrogroupname.macroname syntax for the macroname argument to run a particular macro in a macro group.

If you specify the repeatexpression argument and leave the repeatcount argument blank, you must include the repeatcount argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.


Example
The following example runs the macro Print Sales that will print the sales report twice:

DoCmd.RunMacro "Print Sales", 2
Nov 18 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sylvia | last post by:
Dear All, Would appreciate if someone can help me out on this. I have an Excel Add-in which is only available on the web server. The Add-in allows user to retrieve data from a proprietary...
1
by: Daylor | last post by:
i have solution of window application and assemblies , i alway forget to rebuild the solotion after i change the code in the assemblies. is there way to tell the ide, to rebuild soloution each...
2
by: E Harris | last post by:
Hello all. I want to schedule an Access macro to run. The macro runs 3 make-table queries. The best way I thought to accomplish this is to create a shortcut, and then use the task scheduler...
6
by: geronimo_me | last post by:
Hi, I am trying to run an Excel macro from an Access module, however when I run the code the macro runs but then I get an error in Access. The error is: Run-time error "440", Automation error. ...
8
by: Shooter4Life8 | last post by:
I am trying to run a macro from my VB.NET program. Here is my code. Dim myAccess As Access.Application Dim allMacro As String = "ALL-Macros" myAccess.DoCmd.RunMacro(allMacro) I get the error....
2
by: mscurto | last post by:
Is there a way to set up access to open and run a query in a particular database at a particular time each day? This would be run from a Windows 2000 desktop.
1
by: questionit | last post by:
How do i link a Query with a macro. When i run a query, i want the macro to run as well at same time. I have tried running macro itself, it runs fine but i want macro to run when i run the...
0
by: A1000ma | last post by:
I am trying to develop a C# program to fill in the blanks in a Word Form. Everything works beautifully while the program is running. I had to go in to fix some links on our Web Site a couple of...
1
by: skennd | last post by:
Hello, All your help is appreciated in this problem. I am running a macro to execute certain queries and the macro is started to run by a windows task scheduler. However, after the macro runs...
1
by: ElPresidente | last post by:
Hi everyone, I had a macro I wrote in VBA which created several dozen spreadsheets based off a master spreadsheet. Code runs smoothly in VBA, but trying to port it over to VB caused significant...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.