pduran
11-22-2006, 07:29 AM
Hi all
I'm new in access and i'm sure this should be an easy one, but...
I have a report that i want to print several times, each time with a diferent title. Is it possible to have a text box or label and change it betwen prints? (OpenReport in a macro)
I could have several reports on this access but then it would be too heavy!
Any ideas?
Many thanks
Paulo Duran
Matt Greatorex
11-22-2006, 07:37 AM
Is the data on the report going to be unchanged? If so and all you want is a different title, you could have, say, five text boxes on a form, along with a button. The user enters up to five different titles and clicks on the button. The code says something like
Open report XYZ in design mode
Set it's title to the first text box value
Save the change
Print it
If the second text box isn't empty, repeat for text box 2
If the third text box isn't empty, etc, etc.
Any use?
gemma-the-husky
11-22-2006, 07:42 AM
in the open event for the report, set the label to whatever you want - caption is the property you need
reportlabel.caption = "whatever i need"
pduran
11-22-2006, 07:52 AM
Thank you Matt and Gemma,
This report is an invoice. I need 3 copies (one original to the client and 2 internal "process" and "account") and they must be automatic or some of the copies will miss. that why i think the button option is not the best for me. I think the "reportlabel.caption = "whatever i need" should be the way... but i cant find where do i code that!
thanks
Paulo Duran
KeithG
11-22-2006, 08:21 AM
I would just create three sepeate copies of the report.
pduran
11-22-2006, 08:23 AM
I say that on my original post. the report have several images and its quite big. If i have 3 reports ... Its too big to send through the net.
boblarson
11-22-2006, 08:27 AM
I was trying to test different code for this and I can't get it to work. I know that there is a way to change labels on the report at run time but I can't figure out how to get it to print in between. I keep getting an error.
KeithG
11-22-2006, 08:29 AM
What do you mean it is to big to send through the net? Are you sending the hole database?
If you don't want to create the seperate reports then you will need to create a custom procedure to change the title and print the report. You could also add a parameter to prompt for the title.
gemma-the-husky
11-22-2006, 08:33 AM
I know you can do this other ways, but i generally use global variables.
you need a globavariable "timesprinted"
then in the openreport have
select case timesprinted
case 1: reporttitle.caption = "first copy"
case 2: reporttitle.caption = "second copy"
case 3: reporttitle.caption = "third copy"
end select
however you print the invoice in code, you then need
for timesprinted = 1 to 3
docmd.openreport "myinvoice"
next timesprinted
pduran
11-22-2006, 09:33 AM
Gemma
I wrote your code in a button on a form and it doesnt do anything! No error, no label with caption changed... nothing!
It like it just ignores the code! its incredible!
gemma-the-husky
11-22-2006, 10:25 AM
it may depend how Access actually manages the value of a control loop.
perhaps you have to say instead
dim index as long
for index = 1 to 3
timesprinted = index
docmd.openreport "myinvoice"
next index
however, i also assume you have changed the reporttitle label to whatever you label you are actually using.