Continuous form, forecolor blues

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Windows XP, MS Access 2000
===========================
Hi,

I have a form with default view set to "Continuous Form".
I have 2 textbox controls on the form - Number and
personName. There is only one table, with the following
fields - Number, personName and personStatus. The source
for the form is a query based on this table, and with the
3 fields. I'd like to display the name of the person in a
different color based on the value of the personStatus.
If personStatus = Active, personName.font_color = black
If personStatus = Inactive, personName.font_color = red.

I have the following code:
========================================================
Dim lngRed As Long, lngBlack As Long

lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)

If Me.personStatus = "Inactive" Then
Me!personName.ForeColor = lngRed
Else
Me!personName.ForeColor = lngBlack
End If
End Sub
=========================================================

in the form's OnCurrent section. It's not quite working.
What it does is it turns the color for ALL the records on
the form to either black or red, depending on the
focus/cursor and the value of personStatus for that
particular record.

Obviously, I need to place this code in a different
section. But, I'm not sure where. Any help or pointers
will be much appreciated.

As a note, the ideal situation would be to have the form
in Datasheet view, and display the names in different
colors. Is that possible? From my internet search, it
seems like an easier proposition to format the form in
Continuous view and have it mimic the Datasheet view, than
to format in Datasheet view.

Thanks!

-Amit
 
Use conditional formatiing, not code.

Rick B


Windows XP, MS Access 2000
===========================
Hi,

I have a form with default view set to "Continuous Form".
I have 2 textbox controls on the form - Number and
personName. There is only one table, with the following
fields - Number, personName and personStatus. The source
for the form is a query based on this table, and with the
3 fields. I'd like to display the name of the person in a
different color based on the value of the personStatus.
If personStatus = Active, personName.font_color = black
If personStatus = Inactive, personName.font_color = red.

I have the following code:
========================================================
Dim lngRed As Long, lngBlack As Long

lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)

If Me.personStatus = "Inactive" Then
Me!personName.ForeColor = lngRed
Else
Me!personName.ForeColor = lngBlack
End If
End Sub
=========================================================

in the form's OnCurrent section. It's not quite working.
What it does is it turns the color for ALL the records on
the form to either black or red, depending on the
focus/cursor and the value of personStatus for that
particular record.

Obviously, I need to place this code in a different
section. But, I'm not sure where. Any help or pointers
will be much appreciated.

As a note, the ideal situation would be to have the form
in Datasheet view, and display the names in different
colors. Is that possible? From my internet search, it
seems like an easier proposition to format the form in
Continuous view and have it mimic the Datasheet view, than
to format in Datasheet view.

Thanks!

-Amit
 
Amit,
A continuous form is actually only a single form that recreates several
instances of the form to be viewed. Thus, whatever format appears on one
instance of the form will appear on all instances. You will probably need to
look at using conditional formatting of a datasheet.
 
-----Original Message-----
Use conditional formatiing, not code.

Rick,

I did look at Conditional formatting, but was unable to
figure out how to apply the formatting to one control
based on the value of another control. It seems that the
conditional formatting works only to format a control
based on its own value. If you (or someone else) can show
me how to do conditional formatting, it'll be helpful.

-Amit
 
You would set the conditional formating condition drop-down to "Expression
is" and then set the expression to something like...

[PersonStatus] = "Active"




Rick B




-----Original Message-----
Use conditional formatiing, not code.

Rick,

I did look at Conditional formatting, but was unable to
figure out how to apply the formatting to one control
based on the value of another control. It seems that the
conditional formatting works only to format a control
based on its own value. If you (or someone else) can show
me how to do conditional formatting, it'll be helpful.

-Amit
 
-----Original Message-----
You would set the conditional formating condition drop- down to "Expression
is" and then set the expression to something like...

[PersonStatus] = "Active"

Thanks! That worked :)

-Amit
 
Back
Top