controlling backcolor for records in a report

G

Guest

I have created a report which list work tickets with the date the ticket was
authorized for work to begin. i have included a check box that indicates if
the job is complete. I have been asked to change the color of the record in
the report to futher identify what is complete. for example if job number one
is complete the text boxes for that job should be gray, if incomplete the
backcolor it will still be white. i have tried to use the setvalue method
based on the value of the check box. but this turns out to be all or nothing,
either all records are grayed out or all white depending on the vaule of the
check box.
what is the best way to do this on each individual record?
here is a sample of the code:

With CodeContextObject
If (.ckbxComp = -1) Then
Reports![E07 Auth FMR/Drawing Check List]!jobsummary.BackColor =
255
End If
If (Not .ckbxComp = -1) Then
Reports![E07 Auth FMR/Drawing Check List]!jobsummary.BackColor =
16777215
End If
End With
 
L

Larry Linson

Warden said:
I have created a report which list work
tickets with the date the ticket was
authorized for work to begin. i have
included a check box that indicates if
the job is complete. I have been asked
to change the color of the record in
the report to futher identify what is
complete. for example if job number one
is complete the text boxes for that job
should be gray, if incomplete the
backcolor it will still be white.

It's not at all clear to me what your code was trying to do nor where you
located it, so I have opted to start over rather than offer comments on your
code.

Unlike Forms, Reports do not carry "unused" fields in the recordset they
generate from their RecordSource at execution. So you will need to place a
Control on your Report that has a Control Source of your Yes/No Field. Set
its Visible Property to "No" if you don't want it to be displayed. Then, in
the OnPrint event of the Detail Section, you can use code similar to this

If Me.BackcolorGrey = True Then
Me.Detail.BackColor = 12632256
Else
Me.Detail.BackColor = 16777215
End If

Note that I named my Yes/No field as BackColorGrey for example purposes, so
you will need to replace that with the name of your Field. I referred to the
Field itself, rather than the Control, but could have used

If Me!chkBackcolorGrey = True Then

to refer to the value of the (invisible) Checkbox in which I displayed the
Field.

Larry Linson
Microsoft Access MVP
 

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