Modify a control value in an Access report through VBA

  • Thread starter Thread starter Anja
  • Start date Start date
A

Anja

Hi everyone,

I have been trying this for an hour now but have not been able to make
this work!

So, I have an Access report (actually all it has is a header so far).
What I want to do is modify the header based on the selection the user
has made on a form.

So, if the user chooses 'Anja'. The header should say 'Here are the
options for Anja'.

So, I have a Text Box on th form and I am trying to set the value of
the text box through VBA

So, if my report is called TestReport and the text box is called
NameBox, how can I set the value in the text box and then open the
report???

Please help me!

Anja
 
Unlike forms where you can alter the value in a control any time, reports
format the data and lock it in as the records are fitted to the page, so you
cannot go back and change it later.

You can use the Format event of the section that contains the control to
programmatically assign a value.

But in this case, assuming Form1 is still open in the background, you could
just set the Control Source of your text box to:
= "Here are the options for " & [Forms].[Form1].[Text2]

If you are opening the report via a button on your form (i.e. OpenReport)
and you are using Access 2002 or later, you can pass the description of the
filter in the OpenArgs. There's an example here:
http://allenbrowne.com/AppPrintMgtCode.html#OpenTheReport
Ignore the block about "Set the printer for this report ..."
 

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