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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing all reports with a button!!!!

Status
Not open for further replies.

Kckronic21

Programmer
Jul 29, 2001
81
US
Hi,
I have a question. I have a Center query which looks for the control in the Center form. The criteria in the Center query set up like this: [Forms]![Center_Form]![Center_Name_txtbox].
On the Center form, I have a combo box that list all of the centers from the center table. I created a report based on the Center query that shows one report for each center. The report header has a control source like this: [Forms]![Center_Form]![Center_Name_txtbox]. I have placed a button on the form that prints all of the centers when it is pressed. The Visual Basic code that I have been putting in on that button is like this:

Private Sub CmdPrintAlloftheCentersButton_Click()
[Center_Name_txtbox] = "Center Name 1"
On Error GoTo Err_CmdPrintAlloftheCentersButton_Click

Dim stDocName As String

stDocName = "Center_Report"
DoCmd.OpenReport stDocName, acNormal

[Center_Name_txtbox] = "Center Name 2"

My question is there a way for me to get Access to look at the values that are in the center table (the center names) so that I don’t have to rewrite the same VBA code for each center?

Thanks
 
I'm not sure I fully understand the question, but why not put the centers in another table (a lookup table) or open the query using a querydef. And then in your vba code, loop thru all the records and do a

DoCmd.OpenReport stDocName, acNormal

for each one. (stDocName would be assigned each value as it is read from the recordset)

Hope this helps...

jj
jjones@cybrtyme.com
 
Hi!

It seems to me that you could get rid of the criteria in your query altogether and in your report group on the Center_Name. Put the stuff you have in your report header in the group header, except let the control source for the Center_Name come from the query instead of the form. Then, in the group footer section, put whatever you have in the report footer, if anything, and add a page break control at the end. Now you will only need to run one report and each Center_Name will start a new page.

hth
Jeff Bridgham
 
... or just make the "center" a PARAMETER for the query. Include all of the "Frill" info (a.k.a. "Center Name", et al) in the query. Just do the report from a procedure repeatedly replacing the parameter ...

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top