Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display Form textbox data in Report PageHeader?

Status
Not open for further replies.

aregan1

Programmer
Feb 12, 2002
46
US
Hi everyone -

I'm using Access 2000, and trying to print a field in my report page header that comes from a text box that the user enters into a form.

The text box in the page header of my report is called "PartialCode". The control source for this text box is set to "=[Forms]![Select LD Partial Code].Form!Selected".

This is only partially working!!! When my report displays, the page header of page 1 only correctly displays the "Selected" field from the form. All subsequent report pages display "#Name?" in the page header.

And to make this even more complicated, when I actually print the report, all pages (including page 1) print "#Name?" in the page header.

I must be on the right track, because page 1 is displaying the field on the screen correctly. But how do I get every page of the report to both display and print the correct data that is coming from the form?

Thanks for any help you can offer...

- Anita


 
Anita,
Is this the actual field name on the form?
Form!Selected
If not, then replace your controlsource name with the correct one.
HTH, [pc2]
Randy Smith
California Teachers Association
 
Hi Randy -

Thanks for replying. Yes, "Selected" was actually the name of the text box on my form. But just in case it was a reserved word or something, I changed the name of the form's text box to "Partial". I then changed the report page header text box to use the control source:
=[Forms]![Select LD Partial Code]![Partial]

and I also tried:
=[Forms]![Select LD Partial Code].Form![Partial] in case the .Form made a difference.

I'm still getting the same results. It seems I'm following the instructions that I found on this site in other threads and FAQs. Do you have any other ideas, or other ways of accomplishing the same thing? Thanks...

- Anita
 
Hi again Randy -

I figured out what my problem was. In the code that called my report, the code looked like this:

DoCmd.OpenReport "LD List by Partial Code", acPreview
DoCmd.Close acForm, "Select LD Partial Code"

I tried commenting out the docmd.close statement, and the field from the form now shows up on the page header of every page of the report. I guess the form was open long enough to accurately place the information on page 1 of the report, but the form was already closed when page 2 tried to capture the same data.

So I guess I'll just leave the form open...

- Anita

 
Hi,
You mentioned that you wrote code to open the report. BUT, your code is also closing a form called "Select LD Partial Code". Is this where you placed the code? If so, this probably isn't the correct spot, since users often want to come back to the original selection criteria, and change a few options, and then rerun the report. As soon as the user decides to either print the report, or close the previewed report, the user will automatically return to the calling form.
On the other hand, if you must absolutely close the form, you can create a public variable inside the report to hold the criteria string, and this public variable will be available to the entire report. See item #3 in an FAQ I wrote about how to set up page counts. (faq703-3069)
HTH, [pc2]
Randy Smith
California Teachers Association
 
Hi Randy -

I definitely wanted to close the form after I opened the report, so I used a public variable in the report to hold the value that I needed. It worked great. Thanks...

- Anita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top