A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Is Null Testing for Combo On Opening Form



 
 
Thread Tools Display Modes
  #11  
Old April 4th, 2008, 04:43 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Is Null Testing for Combo On Opening Form

"Access User" wrote in message
...
As is true of the other profers, the effect this has is to not only color
the
background of the field being entered on the form but the background color
of
the three choices appearing in the look up list when the user clicks on
the
down pointing arrow. I would really prefer to have just the entry field on
the form showing up with the red background when it's value is nullity AND
the native black foreground and white background.



I was thinking that you wanted 4 different colors to indicate the states
Good, Fair, Poor, and Null. But I just realized you only want 3 colors to
represent these states, because you say you want the BackColor to be red if
the combo = "Poor" OR it is Null. In that case, you can just modify your
original format condition for "Poor" to change it to be:

Expression Is: [TECHADEQ] = "Poor" OR IsNull([TECHADEQ])

The normal BackColor of the combo would left set to white. I think that
ought to do it.

If you decide you *do* want 4 different colors for the 4 different states, I
believe you can do it using conditional formatting, but it's cumbersome
because conditional formatting supports only three format conditions for a
given control. So what you have to do is change at least one of the format
conditions on the fly.

To do this, you would set up the initial format conditions for your TECHADEQ
combo box as you currently have them. For example, they might be:

Condition1: Field Value Is / equal to / "Poor" -- BackColor =
magenta
Condition2: Field Value Is / equal to / "Fair" -- BackColor =
yellow
Condition3: Field Value Is / equal to / "Good" -- BackColor = green

Then you'd have code in the form's Current event to modify one of the format
conditions, along these lines:

'----- start of example code -----
Private Sub Form_Current()

With Me.TECHADEQ

If IsNull(.Value) Then
.FormatConditions(0).Modify acExpression, , "IsNull([TECHADEQ])"
.FormatConditions(0).BackColor = vbRed
Else
.FormatConditions(0).Modify acFieldValue, acEqual, "Poor"
.FormatConditions(0).BackColor = vbMagenta
End If

End With

End Sub
'----- end of example code -----

I'm not 100% sure this is going to show up right when you first open the
form; it may need some tinkering.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #12  
Old April 4th, 2008, 05:55 PM posted to microsoft.public.access.forms
access user
external usenet poster
 
Posts: 78
Default Is Null Testing for Combo On Opening Form

That's great! It works - my background's still white on the lookup list and
it's red whether it's null or = "Poor".

Brilliant!!

Thank you :-)

"Dirk Goldgar" wrote:

"Access User" wrote in message
...
As is true of the other profers, the effect this has is to not only color
the
background of the field being entered on the form but the background color
of
the three choices appearing in the look up list when the user clicks on
the
down pointing arrow. I would really prefer to have just the entry field on
the form showing up with the red background when it's value is nullity AND
the native black foreground and white background.



I was thinking that you wanted 4 different colors to indicate the states
Good, Fair, Poor, and Null. But I just realized you only want 3 colors to
represent these states, because you say you want the BackColor to be red if
the combo = "Poor" OR it is Null. In that case, you can just modify your
original format condition for "Poor" to change it to be:

Expression Is: [TECHADEQ] = "Poor" OR IsNull([TECHADEQ])

The normal BackColor of the combo would left set to white. I think that
ought to do it.

If you decide you *do* want 4 different colors for the 4 different states, I
believe you can do it using conditional formatting, but it's cumbersome
because conditional formatting supports only three format conditions for a
given control. So what you have to do is change at least one of the format
conditions on the fly.

To do this, you would set up the initial format conditions for your TECHADEQ
combo box as you currently have them. For example, they might be:

Condition1: Field Value Is / equal to / "Poor" -- BackColor =
magenta
Condition2: Field Value Is / equal to / "Fair" -- BackColor =
yellow
Condition3: Field Value Is / equal to / "Good" -- BackColor = green

Then you'd have code in the form's Current event to modify one of the format
conditions, along these lines:

'----- start of example code -----
Private Sub Form_Current()

With Me.TECHADEQ

If IsNull(.Value) Then
.FormatConditions(0).Modify acExpression, , "IsNull([TECHADEQ])"
.FormatConditions(0).BackColor = vbRed
Else
.FormatConditions(0).Modify acFieldValue, acEqual, "Poor"
.FormatConditions(0).BackColor = vbMagenta
End If

End With

End Sub
'----- end of example code -----

I'm not 100% sure this is going to show up right when you first open the
form; it may need some tinkering.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:40 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.