1. Create a table with 2 fields like this:
CopyID Number primary key
CopyColor Number
Enter 3 records, with the copy number and color:
1 16777215
2 65535
3 65280
2. Create a query for your report (if you don't already have one.) As well
as any other tables you need, add the table you just created. The new table
should not have any line joining it to other tables in the upper pane of
table design. This gives you 3 of every record. Make sure the query shows
the 2 fields from the new table.
3. Open your report in design view.
Change its RecordSource property to the new query.
Open the Sorting And Grouping dialog.
Insert a new field above any others in Sorting'n'Grouping, based on the
CopyID field, and set a Group Header for this field. Access will show a new
CopyID Group Header on your report.
4. In the new group header, add a text box for CopyColor.
5. Select the CopyID Group Header, and choose Properties.
Set the On Format property to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Between the "Private Sub..." and "End Sub" lines, insert 3 lines so it looks
like this:
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull(Me.CopyColor) Then
Me.Section("GroupHeader0").BackColor = Me.CopyColor
End If
End Sub
Make sure the "GroupHeader0" name in quotes matches the name Access gave you
for the GroupHeader0 on the "Private Sub ..." line.
How it works:
==========
The colors you stored in the table are RGB values. If you want different
numbers, open the Immediate Window (Ctrl+G), and enter:
? RGB(255, 255, 255)
The 3 numbers in brackets are values for Red, Green, and Blue respectively.
Each number must be between 0 (none) and 255 (max.)
The query without a join is called a Cartesian product. It gives you every
possible combination, so in this case 3 of every record. You can add more
records to the table if you need more than triplicate.
Since the query gives 3 copies of every record, so does the report. You may
need to move some text boxes into the new CopyID Group Header section rather
than the Report Header, so they show on each copy. You can set the Visible
property of the CopyColor text box to No to suppress it. If you have other
text boxes in this header, set their Back Style property to transparent.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
cjgav said:
Hi
I've created a report, when I print it I would like to print 3 copies 1
with
the header back ground in plan 1 in yellow 1 in green .
What is the best way to do this?
Regards