Conditional Formatting

G

Guest

Hello.
I have two fields in a subform one called "Category" and the other called
"HrCost".
I need the "HrCost" field to turn yellow if the "Category" field has
anything starting with either a P. or SP.
For example P. Printer or SP. Workstation

Could you please help with this?

Thanks.
Iram/mcp
 
G

Guest

Try this;

Private Sub Form_Current()

If Left(Me.Category, 2) = "P." Or Left(Me.Category, 3) = "SP." Then

Me.HrCost.ForeColor = vbYellow

Else

Me.HrCost.ForeColor = vbBlack


End If

End Sub
 
F

fredg

Hello.
I have two fields in a subform one called "Category" and the other called
"HrCost".
I need the "HrCost" field to turn yellow if the "Category" field has
anything starting with either a P. or SP.
For example P. Printer or SP. Workstation

Could you please help with this?

Thanks.
Iram/mcp

Select the [HrCost] control.
Click on Format + Conditional Formatting

Set Condition1 to
Expression Is
write
Left([Category],1) = "P" or Left([Category],2) = "SP"
in the next dialog box

set the BackColor to Yellow.
Save the changes.
 
G

Guest

Thanks Fredge.
One last piece of the puzzle I need to add.
If "HrCost" has something in it do not make it orange (only if Null).


Is this possible?

Iram

fredg said:
Hello.
I have two fields in a subform one called "Category" and the other called
"HrCost".
I need the "HrCost" field to turn yellow if the "Category" field has
anything starting with either a P. or SP.
For example P. Printer or SP. Workstation

Could you please help with this?

Thanks.
Iram/mcp

Select the [HrCost] control.
Click on Format + Conditional Formatting

Set Condition1 to
Expression Is
write
Left([Category],1) = "P" or Left([Category],2) = "SP"
in the next dialog box

set the BackColor to Yellow.
Save the changes.
 
G

Guest

This works but I actually need it to work for data that starts with P. or SP.
A period after P or SP.
Left([Category],1)="P" Or Left([Category],2)="SP"
The only problem with this code is that if something like Printer is in the
field the conditional formatting turns the field. The types of data that I
need addressed by conditional formatting is data like SP. Laptops, P.
Printers, SP. Servers, etc...

Your help is greatly appreciated!

Iram/mcp



fredg said:
Hello.
I have two fields in a subform one called "Category" and the other called
"HrCost".
I need the "HrCost" field to turn yellow if the "Category" field has
anything starting with either a P. or SP.
For example P. Printer or SP. Workstation

Could you please help with this?

Thanks.
Iram/mcp

Select the [HrCost] control.
Click on Format + Conditional Formatting

Set Condition1 to
Expression Is
write
Left([Category],1) = "P" or Left([Category],2) = "SP"
in the next dialog box

set the BackColor to Yellow.
Save the changes.
 

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