Re: Passing info to a report from a form
- From: fredg <fgutkind@xxxxxxxxxxxxxxx>
- Date: Mon, 18 Dec 2006 10:02:45 -0800
On Mon, 18 Dec 2006 09:14:00 -0800, Paul Kraemer wrote:
Hi,
I have created a report in Access 2002. I print this report through VBA
code behind a paricular form by calling the DoCmd.OpenReport command when a
"Print" button is clicked.
I would like to be able to pass some textual information from the form so
that it can be printed on the report as heading information. I can do this
if the textual information exists in a TextBox on the form. I just add a
TextBox to the report and set its ControlSource property to
"=Forms!MyForm!MyTextBox".
This works, but sometimes the information I want to pass is not contained in
a TextBox on the form. I can create hidden TextBoxes to use for this purpose
and copy the information to them that I want to pass, but I was just
wondering if there was an easier way. I can think of two things that would
be useful if they were possible:
1. Create TextBoxes on the report. In code behind the form, open up the
report and copy text to these texboxes before printing.
2. In code behind the form, create public variables (or public functions
that would return these variables). Then create TextBoxes on the report that
could access these public variables or functions.
I wasn't able to figure out how to do either of these things. If anyone
could tell me if they are possible, or if there is another way that I can
pass info to my report, I would appreciate it.
Thanks,
Paul
Access 2002 (and newer) has an OpenArgs argument in the OpenReport
method.
Use it.....
DoCmd.OpenReport "Report Name", acViewPreview, , , , "This is to show
in a report."
You could then have an unbound text control in the report.
Set it's control source to:
=[OpenArgs]
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.
- Follow-Ups:
- Re: Passing info to a report from a form
- From: Paul Kraemer
- Re: Passing info to a report from a form
- Prev by Date: Re: Chart Displays [...] Solved
- Next by Date: Re: Passing info to a report from a form
- Previous by thread: Re: Gantt style chart
- Next by thread: Re: Passing info to a report from a form
- Index(es):