Macro for running a report?

G

Guest

I have a combo (or could use a list) box on a form based
on a summary query. I want my user to be able to click on
an entry on the combo or list box and run a report. What's
the best way of doing this? So far I haven't had any luck
with either conditional or regular macros.
 
B

Brendan Reynolds

Dunno about macros, but assuming the bound column of the combo box contains
the name of the report, the following single line of VBA code in the
AfterUpdate event procedure of the combo box will do it ...

DoCmd.OpenReport Me!ComboName, acViewPreview

.... where "ComboName" is the name of your combo box, and I'm assuming you
want to open the report in print preview mode.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
G

Guest

Thanks for the reply, Brendan. There is only one report.
This report should be generated based on the criteria that
is selected in the combo box. That's the problem. It
either reports on all the items in the combo box or a
blank report on none of them.
 
Top