Report printing

J

jamccarley

I created a data base that will eliminate a 3page carbon paper, but we still
need three different printouts to go out on the floor on the machines. I
wrote code that prints the same report three time, changing the backgound
color on each printout. It works, but the problem I am having is it only
prints the first record in the table. I want it to print the record that was
just entered. My command button is named "Command590" , the report is "White
Copy" and my number field is "Control_number". Here is the code I have so far.

Form code
Private Sub Command590_Click()
Dim S As String
S = "Control_number" & Me.Label509
Call DoCmd.OpenReport("White Copy", acViewNormal, , S, acWindowNormal, 1)
Call DoCmd.OpenReport("White Copy", acViewNormal, , S, acWindowNormal, 2)
Call DoCmd.OpenReport("White Copy", acViewNormal, , S, acWindowNormal, 3)
End Sub

and the Report code is
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Me.FillStyle = 0
Select Case Me.OpenArgs
Case 1
Me.Detail.BackColor = vbWhite

Case 2
Me.Detail.BackColor = vbMagenta

Case 3
Me.Detail.BackColor = vbYellow

End Select

End Sub

Thanks
 
D

Duane Hookom

I would consider creating a table of numbers with a single field and number 1
through whatever. Assuming tblNums with field Num and values 1-3. If you add
this table to your report's record source, you will print 3 copies of every
record. You can set this up with the sorting and grouping to print 3 copies
of the report.
 
J

John Spencer (MVP)

I suspect that your where string (S) is not giving you the expected value for
two reasons. One you are missing the equals sign. Secondly if Me.Label509 is
a label, you probably want the value of the caption. I think that if label509
is really a label, that you should be getting an error message - "Object
doesn't support ..."

Try the following
S = "Control_Number =" & me.Label509

If it works fine. If not, post back and tell us what type of control Label509 is.

Oh, by the way meaningful names for controls you use (especially in code) make
things a lot clearer.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

jamccarley

I added the equal sign and I changed the Me.Label509 to Me.Control_number,
which is the field and not the label, but it now works. Thank you

Josh McCarley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top