Alex Gordon
Alex Gordon

Reputation: 60711

using IF statement instead of conditional formatting

since it seems that my conditional formatting statement is way too big:

([Panels] like '*IT_AMPH,*' or [Panels] like '*AMPH_SN,*' or [Panels] like '*AMPH_S,*') and
([Panels] like '*IT_BARB,*' or [Panels] like '*BARB_SN,*' or [Panels] like '*BARB_S,*') and
([Panels] like '*IT_BENZ,*' or [Panels] like '*BENZ_SN,*' or [Panels] like '*BENZ_S,*') and
([Panels] like '*IT_BUP,*' or [Panels] like '*BUP_SN,*' or [Panels] like '*BUP_S,*') and
([Panels] like '*IT_SOMA,*' or [Panels] like '*SOMA_SN,*' or [Panels] like '*SOMA_S,*') and
([Panels] like '*IT_FEN,*' or [Panels] like '*FEN_SN,*' or [Panels] like '*FEN_S,*') and
([Panels] like '*IT_MEP,*' or [Panels] like '*MEP_SN,*' or [Panels] like '*MEP_S,*') and
([Panels] like '*IT_METD,*' or [Panels] like '*METD_SN,*' or [Panels] like '*METD_S,*') and
([Panels] like '*MPH,*') and
([Panels] like '*IT_OPIA,*' or [Panels] like '*OPIA_SN,*' or [Panels] like '*OPIA_S,*') and
([Panels] like '*IT_OXYC,*' or [Panels] like '*OXY_SN,*' or [Panels] like '*OXY_S,*') and
([Panels] like '*IT_PROPX,*' or [Panels] like '*PROPX_SN,*' or [Panels] like '*PROPX_S,*') and
([Panels] like '*TAP,*' or [Panels] like '*TAP_SN,*' or [Panels] like '*TAP_S,*') and
([Panels] like '*IT_TRAM,*' or [Panels] like '*TRAM_SN,*' or [Panels] like '*TRAM_S,*') and
([Panels] like '*IT_TCA,*' or [Panels] like '*TCA_SN,*' or [Panels] like '*TCA_S,*') and
([Panels] like '*IT_COCN,*' or [Panels] like '*COCN_SN,*' or [Panels] like '*COCN_S,*') and
([Panels] like '*IT_6-MAM,*' or [Panels] like '*6-MAM_SN,*' or [Panels] like '*6-MAM_S,*') and
([Panels] like '*IT_MDMA,*' or [Panels] like '*MDMA_SN,*' or [Panels] like '*MDMA_S,*') and
([Panels] like '*IT_PCP,*' or [Panels] like '*PCP_SN,*' or [Panels] like '*PCP_S,*') and
([Panels] like '*IT_THC50,*' or [Panels] like '*THC_SN,*' or [Panels] like '*THC_S,*') and
([Panels] like '*ETOH_S,*' or [Panels] like '*ETOH,*') and
([Panels] like '*NIC,*') and
([Panels] like '*IT_ETG,*' or [Panels] like '*ETG_SN,*' or [Panels] like '*ETG_S,*')

i am thinking that perhaps i should do an IF statement instead of conditonal formatting. for example if the above statement is true then set the textbox font color to black

my question is will it work?

if i do an IF statement for Report_Load on the above statement, will it work as well as conditional formatting?

if so, then how would i do it? please give me some code?

Upvotes: 0

Views: 592

Answers (1)

HansUp
HansUp

Reputation: 97101

Consider using your complex condition in the expression for a hidden text box. You could then reference the hidden text box in a simplified conditional formatting rule.

I created txtStatus as a hidden text box, with this expression as its Control Source (foo_text is a field in the form's record source):

=IIf([foo_text] Like 'child*',1,0)

Then for the text box I display, I added a condition "Expression Is" for:

[txtStatus]>0

... and assigned red for the text attribute when the condition is True.

Maybe a similar approach can work for you.

Upvotes: 1

Related Questions