Conditional Formatting in Code Not Working

T

TotallyConfused

I had posted before with help on syntax for conditional formatting code. I
had used up my options in Conditional Formatting and only need two more
conditions. I provided code and this revised version of what I had provided
to the post returned. But it is not working. What I want is if Office ID =
1 or 2 then Pt Name text box back color to = 33023. Thank you in advance for
any help you can provide.
Private Sub Form Current()

If Me![FieldName] = 1 or Me![FieldName] = 2 Then
 
G

geppo

Ciao said:
I had posted before with help on syntax for conditional formatting
code. I had used up my options in Conditional Formatting and only
need two more conditions. I provided code and this revised version
of what I had provided to the post returned. But it is not working.
What I want is if Office ID = 1 or 2 then Pt Name text box back color
to = 33023. Thank you in advance for any help you can provide.
Private Sub Form Current()

If Me![FieldName] = 1 or Me![FieldName] = 2 Then
Me!PtName.BackColor = 33023
Else
Me!PtName.BackColor = 0
End If


If Office id is a datum type numerical this it has to work.

Otherwise, if the datum is type text you contain among double apexes (" ").

have you changed FieldName with the name of the control Id?
 
T

TotallyConfused

Hi Thank you for responding. Yes I changed the field name to Office Id.
Office Id is a numeric field. Okay on further testing this works in form
view. My sub form is in datasheet view. Therefore, the color is not
showing. How can I make this work?? Thank you for any help you can provide.

geppo said:
Ciao said:
I had posted before with help on syntax for conditional formatting
code. I had used up my options in Conditional Formatting and only
need two more conditions. I provided code and this revised version
of what I had provided to the post returned. But it is not working.
What I want is if Office ID = 1 or 2 then Pt Name text box back color
to = 33023. Thank you in advance for any help you can provide.
Private Sub Form Current()

If Me![FieldName] = 1 or Me![FieldName] = 2 Then
Me!PtName.BackColor = 33023
Else
Me!PtName.BackColor = 0
End If


If Office id is a datum type numerical this it has to work.

Otherwise, if the datum is type text you contain among double apexes (" ").

have you changed FieldName with the name of the control Id?
 
G

geppo

Ciao said:
Hi Thank you for responding. Yes I changed the field name to Office
Id. Office Id is a numeric field. Okay on further testing this works
in form view. My sub form is in datasheet view. Therefore, the
color is not showing. How can I make this work?? Thank you for any
help you can provide.


If the things are so, then he is not able' to do.

You can use only her "conditional formatting."

For instance:

private sub form_load ()

Me!ptName.FormatConditions.Add acExpression, "[ID]=1 or [id]=2"
Me!ptName.FormatConditions(0). BackColor = 33023

end sub
 
T

TotallyConfused

Grrrr!!! this is not working either. What gives? There should be a way to
make this work. I have typed everything the way you posted. How can I
replicate the Conditional Formatting via menu bar in Code?

geppo said:
Ciao said:
Hi Thank you for responding. Yes I changed the field name to Office
Id. Office Id is a numeric field. Okay on further testing this works
in form view. My sub form is in datasheet view. Therefore, the
color is not showing. How can I make this work?? Thank you for any
help you can provide.


If the things are so, then he is not able' to do.

You can use only her "conditional formatting."

For instance:

private sub form_load ()

Me!ptName.FormatConditions.Add acExpression, "[ID]=1 or [id]=2"
Me!ptName.FormatConditions(0). BackColor = 33023

end sub
 
G

geppo

Ciao said:
Grrrr!!! this is not working either. What gives? There should be a
way to make this work. I have typed everything the way you posted.
How can I replicate the Conditional Formatting via menu bar in Code?

If you have that version of access you have?

The "conditional formatting" he is able' to get then only from the version
of Access2000 in.

If it is able you' to be here of help from the one glance

http://www.lebans.com/formatbycriteria.htm
 
S

Stephen Lebans

The more relevant sample is here:
http://www.lebans.com/conditionalformatting.htm
A2K or Higher Only!

New Feb 08,2002. Added support for Datasheet view and SubForms.

A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View

Version 2.7

Added sample demonstrating how to achieve a background Hover/Highlighting of
rows for a form in Continuous view.

Version 2.3

Added sample demonstrating how to achieve pseudo enable/disable of an
unbound control on a form in Continuous View.

Version 1.9

Added sample form to show how to apply conditional formatting to based on a
Boolean(Yes/No) field.

Verrsion 1.8


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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