conditional formatting problem

K

Keith G Hicks

I have this code in the form's OnCurrent event handler:

Dim cf As FormatCondition
Set cf = Me.FolderDesc.FormatConditions.Add(acFieldValue, acEqual,
"Covers")
cf.BackColor = vbBlue


The form is set to datasheet.

When I run it, nothing happens. The form shows as if I didn't have any
conditional formatting. When I set it up in property settings it works
fine. Not sure what I'm doing wrong in code. I need 4 conditions. The
property settiings looks like you can only have up to 3 conditions. Can I do
more in code or am I still limited to 3?

Please don' t point me to Lebans site. I'm looking for a specifica anser in
this NG.

Thanks,

Keith
 
K

Keith G Hicks

Well I realized from looking at Stephen's examples this should be in the
form's OnLoad event. I did that but it still doesn't work.

I have this code in the form's OnCurrent event handler:

Dim cf As FormatCondition
Set cf = Me.FolderDesc.FormatConditions.Add(acFieldValue, acEqual,
"Covers")
cf.BackColor = vbBlue


The form is set to datasheet.

When I run it, nothing happens. The form shows as if I didn't have any
conditional formatting. When I set it up in property settings it works
fine. Not sure what I'm doing wrong in code. I need 4 conditions. The
property settiings looks like you can only have up to 3 conditions. Can I do
more in code or am I still limited to 3?

Please don' t point me to Lebans site. I'm looking for a specifica anser in
this NG.

Thanks,

Keith
 
K

Keith G Hicks

Ok. I got this to work with the following code in the form's OnLoad handler:

Set cf1 = Me.FolderDesc.FormatConditions.Add(acExpression, ,
"[FolderDesc]=""Manila""")
Me.FolderDesc.FormatConditions(1).BackColor = ManilaColor

I have one more problem though. I need 4 conditions and it appears that I
can only use 3. Is there a way around that? Why the heck would they limit
this to 3? Seems sorta dumb.

These all work:

....FormatConditions(0)...
....FormatConditions(1)...
....FormatConditions(2)...

But this crashes:

....FormatConditions(3)...

Keith
 
K

Keith G Hicks

Well I hope I didn't offend Mr. Lebans or any of your fans. I re-read my
first post and realized that I worded that funny. What I didn't want was for
a whole bunch of folks to just post the linke to the Lebans site. I've been
there many times and found lots of useful information. I am definitely a
fan. I was just looking for a specific answer to my questions. Hoping
someone can anser my latest question about the max number of conditional
formats.

Keith
 
M

Marshall Barton

Keith said:
Ok. I got this to work with the following code in the form's OnLoad handler:

Set cf1 = Me.FolderDesc.FormatConditions.Add(acExpression, ,
"[FolderDesc]=""Manila""")
Me.FolderDesc.FormatConditions(1).BackColor = ManilaColor

I have one more problem though. I need 4 conditions and it appears that I
can only use 3. Is there a way around that? Why the heck would they limit
this to 3? Seems sorta dumb.


It's not dumb if it takes too long to process the additional
condifions. This feature is slow enough as it is. Don't
forget that every control's CF conditions must be processed
every time the form is repositioned, sized, and some
controls just when the focus changes, there's a LOT of work
going on with this feature.

Now to your technical question ;-)

You can test as many conditions as you want by using And/Or
in a single CF entry. You can even call a public function
in a standard module to perform some really elaborate
condition checks. The thing you are probably complaining
about is that you can only specify the default and 3
conditional sets of properties. This is a hard limit so if
you want more colors, you will not be able to use datasheet
view.
 

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

Similar Threads


Top