Help. Need simple switchboard button to run multiple reports

B

BruceNorris

Access 2002

I'm an Excel coder and have inherited an Access db. It has a
switchboard with buttons that successfully print single reports. I now
want to create one button that prints all those reports with just one
click. Is that possible? With the switchboard manager, I added a button
and set the command as OpenReport, but it seemed I could enter only one
report name, am I seeing that correctly?

Assuming that's correct, I guessed I have to write a macro and have the
button run that code, is that right? If so, should I set the
switchboard button to RunMacro or RunCode? What's the difference? And
where should I write the code in a new module, enter it as a macro, or
write it in with the switchboard code? -confused.

I thought the code would be simple like this, right?

Sub RunBfrRpts()
DoCmd.OpenReport "rpt001", acViewNormal
DoCmd.OpenReport "rpt002", acViewNormal
DoCmd.OpenReport "rpt003", acViewNormal
End Sub

Anyway, could someone point me in the right direction?

Thanks,
Bruce
 
F

fredg

Access 2002

I'm an Excel coder and have inherited an Access db. It has a
switchboard with buttons that successfully print single reports. I now
want to create one button that prints all those reports with just one
click. Is that possible? With the switchboard manager, I added a button
and set the command as OpenReport, but it seemed I could enter only one
report name, am I seeing that correctly?

Assuming that's correct, I guessed I have to write a macro and have the
button run that code, is that right? If so, should I set the
switchboard button to RunMacro or RunCode? What's the difference? And
where should I write the code in a new module, enter it as a macro, or
write it in with the switchboard code? -confused.

I thought the code would be simple like this, right?

Sub RunBfrRpts()
DoCmd.OpenReport "rpt001", acViewNormal
DoCmd.OpenReport "rpt002", acViewNormal
DoCmd.OpenReport "rpt003", acViewNormal
End Sub

Anyway, could someone point me in the right direction?

Thanks,
Bruce

One of the problems with the built in Access switchboard is that it is
not very adaptable.

To run several reports at the click of one button, place your above
RunBfrRpts code in a new MODULE.
Then, using the switchboard manager to edit the switchboard page, set
the button to Run Code. Write
RunBfrRpts
in the Function Name dialog box.

Note, since acNormal is the default, there is no need to write it,
i.e. DoCmd.OpenReport "rpt001" (without ,acNormal) will print without
previewing.
 
B

Bruce Norris

One of the problems with the built in Access switchboard is that it is
not very adaptable.

To run several reports at the click of one button, place your above
RunBfrRpts code in a new MODULE.
Then, using the switchboard manager to edit the switchboard page, set
the button to Run Code. Write
RunBfrRpts
in the Function Name dialog box.

Note, since acNormal is the default, there is no need to write it,
i.e. DoCmd.OpenReport "rpt001" (without ,acNormal) will print without
previewing.

Thanks, Fred.

I wrote the code in a new module (Module1) as Sub RunBfrRpts(). In
switchboard manager, I edited the button to Run Code and entered
RunBfrRpts. As a test, I wrote the procedure to run just one report,
but am getting this when I click the switchboard button:
"There was an error executing the command."

Do I need to prefix the function call as Module1.RunBfrRpts or anything
like that?

If that's not the problem, I suspect I'm writing the module in the
wrong db file. This system contains many Access db's where the
switchboard table is in one main db and linked to all the others. So,
the main db serves as a central controller for the switchboards in all
the other db's. And the other db's seemingly have been built with main
being a template of some sort. They contain tables and reports of thier
own but all built with the same structure as each other. So, I suspect
the module I built in the main db isn't being read by the db I'm in
when I operate the switchboard. Does that make sense?

I tried building the module directly in one of the other db's, but it
wouldn't let me save it, saying I didn't have exclusive rights. What is
that?

Sorry for my ignorance. This is probebly a simple thing, but I'm just
not very experienced with switchboard. As you probebly know, in Excel
we program forms from scratch, so I'm not used to working things this
way. Thanks for your patience.

What do you think I need to do?

-Bruce
 
B

Bruce Norris

...
I tried building the module directly in one of the other db's, but it
wouldn't let me save it, saying I didn't have exclusive rights. What is
that?
...

Sorry, that should have read exclusive ACCESS, not rights. It said I
can't save changes because I don't have exclusive access. Does that
mean someone else has the file open? It is on an intranet, so that's
possible, but how can I prevent others working in it while I'm tweaking
it?

-Bruce
 

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