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

How can I print variations of a report with 1 click of "Print"?

Status
Not open for further replies.

aregan1

Programmer
Feb 12, 2002
46
US
I'm fairly new to Access (2000), and am stumped with a report printing problem.

I have generated an Access report which is a work order, listing multiple tasks related to each specific work order (along with other info). When the user previews the report, they only need to see one work order, with all the tasks listed.

However, when the report prints, I need to print one copy of the work order for each task listed on the report. All the copies of the report will look similar, with one exception: each copy of the work order will have a different task highlighted in some way. (I'm currently putting a rectangle around the highlighted task). So if there are 3 tasks on the work order, I will print 3 sheets of paper that seem identical, except for the different highlighted tasks. (The separate sheets of paper can then be handed off to different technicians to complete the tasks).

Essentially, what I want to do when a user clicks on the printer icon is take control myself (as if there was an "OnPrint" event, which I don't believe there is), and perform formatting and printing commands myself, such as:

highlight task 1
print work order
un-highlight task 1
hightlight task 2
print work order
unhighlight task 2
highlight task 3
print work order

Can anyone tell me if this is even possible, and if so, how to go about it? Thanks in advance for your help...

- Anita
 
First you've got to find a way to count how many tasks there actually are on each Work Order. Do you have any way to do this? For exmaple could you create a query that GroupsBy the Work Order Number and Counts the Tasks? Are they listed as Task1, Task2.....Taskn? We somehow need to get the highest value inorder to use that number to do the rest.

Paul
 
Hi Paul -

I print the work order tasks within the groupfooter of the report, and I determine which tasks to print (and how many) within the GroupFooter0_Format event. Right now, there is no field within the data that tells me how many tasks to print. I determine that based on other data in the record, and format the tasks accordingly. (There are only 5 possible tasks, and I will always print at least 2 but no more than 3 of the 5 choices, based on the type of data in the record.)

So to answer your question: Yes, I can determine how many tasks need to print, but only within the GroupFooter0_Format code. That information is not within the data itself.

P.S. I realize that an option is to execute a query prior to executing the report, that will add the information I need to the recordset that the report reads. I was just hoping there was a way to do this without the extra query step.

Thanks for you help...

- Anita
 

Can you post the GroupFooter format event? It's possible we could set up a loop that would increment an integer that we could use to highlight the Task Field.

Paul
 
Hi Paul -

Here's the code I have now in the groupfooter_format event. Note: I designed the group footer controls with a row set up for each of the possible 5 tasks. I set the "can shrink" property to yes for all the controls in these rows. Based on the data in the record, I make all the controls for a task invisible if that task should not print. So only the appropriate tasks actually print, and there are no blank lines printing to make things look strange.

Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)

' Should the MN(Monitor) task print?
If MNneeded.Value = False Then
LabelMN.Visible = False
MNstart.Visible = False
MNend.Visible = False
MNbox.Visible = False
MNbox2.Visible = False
Else
LabelMN.Visible = True
MNstart.Visible = True
MNend.Visible = True
MNbox.Visible = True
MNbox2.Visible = True
End If

' Either the DS(Delivery and Service) or CustPickup task should always print
If DSneeded.Value = False Then
DSdate.Visible = False
LabelDS.Visible = False
DSstart.Visible = False
DSbox.Visible = False
Dsbox2.Visible = False
LabelCustPickup.Visible = True
CustPickupTime.Visible = True
EventDate.Visible = True
LabelTech2Signoff.Caption = " Customer Signature"
Else
DSdate.Visible = True
LabelDS.Visible = True
DSstart.Visible = True
DSbox.Visible = True
Dsbox2.Visible = True
LabelCustPickup.Visible = False
CustPickupTime.Visible = False
LabelTech2Signoff.Caption = "Technician 2 Completed?"
If DSdate = EventDate Then
EventDate.Visible = False
Else
EventDate.Visible = True
End If
End If

' Either the PR(Pickup and Return) or CustReturn task should always print
If PRneeded.Value = False Then
LabelPR.Visible = False
PRstart.Visible = False
PRbox.Visible = False
PRbox2.Visible = False
LabelCustReturn.Visible = True
CustReturnTime.Visible = True
Else
LabelPR.Visible = True
PRstart.Visible = True
PRbox.Visible = True
PRbox2.Visible = True
LabelCustReturn.Visible = False
CustReturnTime.Visible = False
End If

If PRdate = EventDate Then
PRdate.Visible = False
Else
PRdate.Visible = True
End If

End Sub
---------------------------------

So based on the code, I will end up printing one of 3 possible combinations of tasks on the work order:
1) DS, MN, PR
2) DS, PR
3) CustPickup, CustReturn

I hope I didn't confuse you, and thanks again...

- Anita



 
Anita, I have looked at this but haven't found any way to do what you need. By the time the Footer Event fires, the damage, so to speak, is done. If you want to pursue manipulating the underlying query let me know and I'll look at it. Maybe someone else has a solution but I couldn't find one. Sorry.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top