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

Changing colour in datasheer

Status
Not open for further replies.

JRVoyager

Programmer
Jun 18, 2003
15
SE
I have a problem that i don´t know how to tackle.
Im programming a database that vill contain measuring values. I would like to make a comparison between a reference value and a measured value, when the measured value dont match the ref value so would i make a visual feedback to the operator that something is wrong.
The feedback should be that the cell with the "faulting" measure turns into a red back colour.

The base value is stored in a form and the measured value in a form inside the other one (could not make ut what its called i english).
 
When you're in the reports design mode, click on the DETAIL part of the report and then scroll down the property list until you find FORMAT. Add this code:

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

If Me.[YOUR FIELD NAME] = YOUR CONDITION Then
Me.Detail.BackColor = 12632256 'light grey
Else
Me.Detail.BackColor = vbWhite
End If

End Sub

All you have to do is enter the field and condition...the rest is generic and will work. Hope this helps.

Jim DeGeorge [wavey]
 
Thanks for the reply, I will test this direcly in the morning. I have been struggling/testing with a similar VBA code but not used the DETAIL part.

My code read

if ...
me.[fieldname].backcolour = "xx
.
.

The result in this case was that all fields with this name became coloured.

Will bee very intresting to see the result
 
Yes, you were using the FIELD's back color not the DETAIL section, which would highlight the entire record not just the field. Let me know if it works.

Jim DeGeorge [wavey]
 
Thanks for your reply.
I have tested the code and it works, it helped me with another problem so the code will be handy in the future.

I see that I have to polish my english a bit so I can put the question in the right way. So I don´t take up your time.

My intention was to manipulate individual cells in a subform. The cells is aligned the same way as they are in the report. Ie we can say that I want to manipulate a individual cell in the report detail. This cell should have different colouring depending on the result from the comparison.

My previous code

IF [cell name] = [Value]
me.[cell name].backcolour = VbRed
else
me.[cell name].backcolour = VbWhite
end if

made the cell, with lable [cell name] at all rows to take the same colour. What i wanted was to get that particular cell (that has the faulting value) to get coloured not all of them.

As our code sample turned out to be handy when it comes to colouring a hole row, raises this a new question
Do you have a solution how to make even row numbers grey and odd row numbers white so the report gets a "stripy" look as this may make reports easier to read.
Is there any RowIndex that can be read and used in an evaluation ?

Thanks very much for your time

Regards

Gerth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top