I have a report that sometimes needs to have each page printed twice with a different footer on each page, the two pages need to print together. I haven't been able to find any way to do this.
I cannot think of a way to do this without creating multiple reports and calling them together. Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
I didn't try and debug the code, but logically here is what I believe will work.
1. Based on the criteria or selection in a field set a flag that is for multiple copies. So If I must have 2 copies set flag to true, if not set flag to false.
2. have a button to click that will run the report.
3. in the on click event for that button, set up an if statement to check the flag. If the flag is false it sets the footer flag to 1 and prints one copy. If the flag is true then it does a for next loop.
If the Counter in the for next loop is < 2 it sets the footer flag to 1 and prints the report, then it loops back up to beginning and adds one to counter, sets Footer flag to 2 and prints report again.
then it ends the for next loop.
4. in the report design, click on the bar that says "Page Footer" then go into the code window and add an if statement for the Footer flag. If the footer flag is 1 then show these controls, or set these control values etc. if it is 2 then set it to something different.
**Code for the On click event of the Print button.
**Threw this together quickly, may need debuging.
Sub Command_PrintReport_Click ()
'Set the multi copy flag
if Forms!MyForm!txt_copies = 1 then
MulticopyFlag = False
elsif forms!MyForm!txt_Copies = 2 then
MulticopyFlag = True
endif
'Check the flag and take appropriate action
FooterFlag = 0
if MultiCopyFlag = true the
For Counter = 1 to 2
FooterFlag = FooterFlag +1
Docmd.OpenReport "YourReportName"
Next Counter
Else
FooterFlag = 1
Docmd.OpenReport "YourReportName"
endif
MsgBox "Your Report is done",vbOkOnly,"Report Status"
end sub
** Code for the Page Footer on your report
If Forms!MyForm!FooterFlag = 1 then
Me.txt_CopyMesage.Value = "This copy for Customer"
Me.txt_ReturnPolicy.Visible = True
Me.lbl_CustomerSignature.Visible = True
Me.lbl_ProprietaryInfo.Visible = False
elseif Forms!MyForm!FooterFlag = 2 then
Me.txt_CopyMessage.Value = "This copy for Office"
Me.txt_ReturnPolisy.Visible = False
Me.lbl_CustomerSignature.Visible = True
Me.lbl_ProprietaryInfo.Visible = True
endif
If I'm not learning, I must be coasting. If I am coasting, I must be going down hill.
** Code for the Page Footer on your report
Private Sub Detail1_Format()
If Forms!MyForm!FooterFlag = 1 then
Me.txt_CopyMesage.Value = "This copy for Customer"
Me.txt_ReturnPolicy.Visible = True
Me.lbl_CustomerSignature.Visible = True
Me.lbl_ProprietaryInfo.Visible = False
elseif Forms!MyForm!FooterFlag = 2 then
Me.txt_CopyMessage.Value = "This copy for Office"
Me.txt_ReturnPolisy.Visible = False
Me.lbl_CustomerSignature.Visible = True
Me.lbl_ProprietaryInfo.Visible = True
endif
End Sub If I'm not learning, I must be coasting. If I am coasting, I must be going down hill.
Your code appears to print the report twice. I need both copies to printed together. It looks to me like the code will produce one run with one footer and the next run with the other footer.
I guess I am confused by what you mean together. If you want each copy to have a different footer you are going to have to print it twice, once with one footer and then the other one with the second footer. They will happen one right after another. You're not going to be able to have the printer grab two pieces of paper and print two different reports (the same report with different footers) at the very same instant. Or are you going to use two different printers?
If I'm not learning, I must be coasting. If I am coasting, I must be going down hill.
Oh ok, I think I understand. You want it to Collate, Print page one with first footer, then print page one with the second footer, then page two ... I would have to do a little research on this. Basically you would have to use the same code as I gave you earlier but with a little twist. See Pseudo code below:
1. Is it multi copy or not = MultiFlag
2. Get the number of pages to be printed = pageqty (Have
to figure this out).
3. set pagectr to 0
Pagecntr = 0
if MultiFlag = True then
For PageCntr = 1 to PageQty
FooterFlag = 0
For copy = 1 to 2
FooterFlag = FooterFlag + 1
docmd.OpenReport ... page(pagecntr) (Have to
figure this out)
Next Copy
Next PageCntr
Else
Docmd.OpenReport ...
endif
The part where it says "page(pagecntr)" is theory that there is a command that will allow you to print the report and pass to the printer to print only the page number that resides in the variable "pagecntr".
I'll research this and let you know what I come up with, unless someone else with more experience comes up with it first.
I'm not sure how long it would take for this to print this way though.
Another option I just thought of might be to use the Mail Merge functionality of Word. Set up a template that can draw from your database to create the reports, one with one footer and another with a different footer. If the criteria exists to print multi copy then it would get the record set from your database and passit to the word template and make it merge the documents.
If I'm not learning, I must be coasting. If I am coasting, I must be going down hill.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.