By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,689 Members | 1,731 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,689 IT Pros & Developers. It's quick & easy.

Conditional Formatting Not Working

P: n/a
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.

Here's what doesn't make sense. The last line of code re-establishes
the focus to the text field with a SetFocus command (i.e.
txtMyField.SetFocus). The field definitely has the focus, but the
conditional formatting (Field Has Focus) is not working. It doesn't
seem to apply the conditional formatting even though the field once
again has focus.

HELP!

Thanks in advance.

Oct 26 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On 26 Oct 2006 14:56:13 -0700, "Typehigh" <nm******@usatoday.com>
wrote:

That's probably by design.
Just like when I programmatically change the value of a control, its
Change event does not fire. But when I manually type a new value, it
does.

-Tom.

>I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.

Here's what doesn't make sense. The last line of code re-establishes
the focus to the text field with a SetFocus command (i.e.
txtMyField.SetFocus). The field definitely has the focus, but the
conditional formatting (Field Has Focus) is not working. It doesn't
seem to apply the conditional formatting even though the field once
again has focus.

HELP!

Thanks in advance.
Oct 27 '06 #2

P: n/a
Tom,

Okay, I accept your assessment of why programmatic changes don't
trigger conditions or events, but can anyone think of a way to "trick"
the application with vba so that conditional formatting will once again
apply itself to the field.
This is an essential element to my application.

Thanks to all of you for taking the time to help each other out.

Neil

Tom van Stiphout wrote:
On 26 Oct 2006 14:56:13 -0700, "Typehigh" <nm******@usatoday.com>
wrote:

That's probably by design.
Just like when I programmatically change the value of a control, its
Change event does not fire. But when I manually type a new value, it
does.

-Tom.

I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.

Here's what doesn't make sense. The last line of code re-establishes
the focus to the text field with a SetFocus command (i.e.
txtMyField.SetFocus). The field definitely has the focus, but the
conditional formatting (Field Has Focus) is not working. It doesn't
seem to apply the conditional formatting even though the field once
again has focus.

HELP!

Thanks in advance.
Oct 27 '06 #3

P: n/a
"Typehigh" <nm******@usatoday.comwrote in news:1161899772.985857.299050
@f16g2000cwb.googlegroups.com:
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.

Here's what doesn't make sense. The last line of code re-establishes
the focus to the text field with a SetFocus command (i.e.
txtMyField.SetFocus). The field definitely has the focus, but the
conditional formatting (Field Has Focus) is not working. It doesn't
seem to apply the conditional formatting even though the field once
again has focus.
What you are describing works for me in Access 2003, that is the
conditional formatting is applied to Text0 (sets backcolor to red) and
Text2 (sets backcolor to blue) when Command4 and Command5 respectively
are clicked.

Private Sub Command4_Click()
Text0.SetFocus
End Sub

Private Sub Command5_Click()
Me.Text2.SetFocus
End Sub

Perhaps you are using a previous version?
or
Perhaps there is something else in your code that prevents the
conditional formatting being applied; in that case you might examine and
test your code or if that fails, post the whole thing here;
or
Perhaps I don't understand.

--
Lyle Fairfield
Oct 27 '06 #4

P: n/a
Lyle,

I just tried it using Access 2003 and had the same results: it's not
working for me.

I just created another db (to recreate my problem) and tried to get the
Conditional Formatting to fail and I couldn't make it happen.

I do have continuous subforms, but even when I jumped all around from
form to form and control to control, I couldn't make the Conditional
Formatting fail like on my current application.

I give up.

Neil
Lyle Fairfield wrote:
"Typehigh" <nm******@usatoday.comwrote in news:1161899772.985857.299050
@f16g2000cwb.googlegroups.com:
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional
formatting is no longer displayed. This part makes sense to me.

Here's what doesn't make sense. The last line of code re-establishes
the focus to the text field with a SetFocus command (i.e.
txtMyField.SetFocus). The field definitely has the focus, but the
conditional formatting (Field Has Focus) is not working. It doesn't
seem to apply the conditional formatting even though the field once
again has focus.

What you are describing works for me in Access 2003, that is the
conditional formatting is applied to Text0 (sets backcolor to red) and
Text2 (sets backcolor to blue) when Command4 and Command5 respectively
are clicked.

Private Sub Command4_Click()
Text0.SetFocus
End Sub

Private Sub Command5_Click()
Me.Text2.SetFocus
End Sub

Perhaps you are using a previous version?
or
Perhaps there is something else in your code that prevents the
conditional formatting being applied; in that case you might examine and
test your code or if that fails, post the whole thing here;
or
Perhaps I don't understand.

--
Lyle Fairfield
Oct 27 '06 #5

P: n/a
"Typehigh" <nm******@usatoday.comwrote in
news:11*********************@i3g2000cwc.googlegrou ps.com:
Lyle,

I just tried it using Access 2003 and had the same results: it's not
working for me.

I just created another db (to recreate my problem) and tried to get
the Conditional Formatting to fail and I couldn't make it happen.

I do have continuous subforms, but even when I jumped all around from
form to form and control to control, I couldn't make the Conditional
Formatting fail like on my current application.

I give up.
Giving up is hard to do ... didn't someone write a song about that?
Regardless it doesn't fit with my style ....

Have you done all the obvious things with your current app?
compact and repair

I'm sure you want to do the simple things before you give up ...

and maybe some not so simple
decompile/compile
(rather than giving up)

saveastext the problem form and then loadfromtext
saveastext 6, "", "newdb.mdb" and then importing all forms and reports
and modules and macros into newdb.mdb?
posting all the code behind the problem form?

and after that ... is the app too big or too secret to zip and share?

Did I mention that I HATE "give up"!

--
Lyle Fairfield
Oct 27 '06 #6

P: n/a

"Lyle Fairfield" <ly***********@aim.comschreef in bericht news:Xn*********************************@216.221.8 1.119...
"Typehigh" <nm******@usatoday.comwrote in
news:11*********************@i3g2000cwc.googlegrou ps.com:
>Lyle,

I just tried it using Access 2003 and had the same results: it's not
working for me.

I just created another db (to recreate my problem) and tried to get
the Conditional Formatting to fail and I couldn't make it happen.

I do have continuous subforms, but even when I jumped all around from
form to form and control to control, I couldn't make the Conditional
Formatting fail like on my current application.

I give up.
Giving up is hard to do ... didn't someone write a song about that?
Regardless it doesn't fit with my style ....
Like:
"A quitter never wins
A winner never quits.
When the going get's tough
The tough get going."
(Randy Newman - Memo to my Son)

Arno R

Oct 27 '06 #7

P: n/a
By the time I post something, I've pretty much tried everything.
Compact and Repair, new db with imported code, everything (but the
solution).
I finally figured out a workaround. I believe the problem stems from
multiple nested routines and something way down deep is killing the
focus. Here's what I did.

Created a button control on my form called cmdResetFocus.
I turned off it's visibility (cmdResetFocus.Visible = False)
Removed all of the Set Focus commands from my nests.
Before calling the subroutines. I set the focus to the cmdResetFocus.
Run the routines.
After the routines are run, I shift the focus to the actual desired
field.
Works like a charm.

Now if someone could only solve this problem I would be golden.

http://groups.google.com/group/comp....0f92512946a461


Lyle Fairfield wrote:
"Typehigh" <nm******@usatoday.comwrote in
news:11*********************@i3g2000cwc.googlegrou ps.com:
Lyle,

I just tried it using Access 2003 and had the same results: it's not
working for me.

I just created another db (to recreate my problem) and tried to get
the Conditional Formatting to fail and I couldn't make it happen.

I do have continuous subforms, but even when I jumped all around from
form to form and control to control, I couldn't make the Conditional
Formatting fail like on my current application.

I give up.

Giving up is hard to do ... didn't someone write a song about that?
Regardless it doesn't fit with my style ....

Have you done all the obvious things with your current app?
compact and repair

I'm sure you want to do the simple things before you give up ...

and maybe some not so simple
decompile/compile
(rather than giving up)

saveastext the problem form and then loadfromtext
saveastext 6, "", "newdb.mdb" and then importing all forms and reports
and modules and macros into newdb.mdb?
posting all the code behind the problem form?

and after that ... is the app too big or too secret to zip and share?

Did I mention that I HATE "give up"!

--
Lyle Fairfield
Oct 27 '06 #8

P: n/a
You need to use Me.Recalc to force conditional formatting.

--
Darryl Kerkeslager
Oct 28 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.