highlight and bold text box if a condition is true

G

Guest

I have a subform with the text field "facility". If the text within this
text field = "shareholder", I need it to be highlighted and bolded. I tried
conditional formatting but it doesn't work the way I want it to. (The field
is bolded and highlighted only after I let go of the scroll bar. I need it
to always be bolded and highlighted.) I tried doing this programmatically in
the after update event of the facility textbox, but it's not working.

Private Sub Facility_AfterUpdate()
If Me.Facility = "SHAREHOLDER" Then

Me.Facility.BackColor = 16777215
Me.Facility.FontWeight = Bold

End If
End Sub


Thanks,
 
G

Graham Mandeno

Hi Tina

I gather from your mention of a scrollbar that this is a continuous form.

If so, then sorry, conditional formatting is your only option.
 
G

Guest

Graham,

Actually the main form is a single form and the subform is a datasheet. The
only reason there is a scroll bar in the subform is because the sometimes
there are just too many records for the screen. Is conditional formatting
still my only option?

Thanks,
--
Tina


Graham Mandeno said:
Hi Tina

I gather from your mention of a scrollbar that this is a continuous form.

If so, then sorry, conditional formatting is your only option.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Tina said:
I have a subform with the text field "facility". If the text within this
text field = "shareholder", I need it to be highlighted and bolded. I
tried
conditional formatting but it doesn't work the way I want it to. (The
field
is bolded and highlighted only after I let go of the scroll bar. I need
it
to always be bolded and highlighted.) I tried doing this programmatically
in
the after update event of the facility textbox, but it's not working.

Private Sub Facility_AfterUpdate()
If Me.Facility = "SHAREHOLDER" Then

Me.Facility.BackColor = 16777215
Me.Facility.FontWeight = Bold

End If
End Sub


Thanks,
 
G

Graham Mandeno

Hi Tina

If the control you want to format is on the subform then, yes, conditional
formatting (CF) is the only option.

If it's on the main form (and you can therefore see only one instance of it
at a time) then you could change the formatting properties in Form_Current.
However, CF should work just as well.

From your mention of the scrollbar, I assumed the form in question was
either continuous or datasheet.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Tina said:
Graham,

Actually the main form is a single form and the subform is a datasheet.
The
only reason there is a scroll bar in the subform is because the sometimes
there are just too many records for the screen. Is conditional formatting
still my only option?

Thanks,
--
Tina


Graham Mandeno said:
Hi Tina

I gather from your mention of a scrollbar that this is a continuous form.

If so, then sorry, conditional formatting is your only option.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Tina said:
I have a subform with the text field "facility". If the text within
this
text field = "shareholder", I need it to be highlighted and bolded. I
tried
conditional formatting but it doesn't work the way I want it to. (The
field
is bolded and highlighted only after I let go of the scroll bar. I
need
it
to always be bolded and highlighted.) I tried doing this
programmatically
in
the after update event of the facility textbox, but it's not working.

Private Sub Facility_AfterUpdate()
If Me.Facility = "SHAREHOLDER" Then

Me.Facility.BackColor = 16777215
Me.Facility.FontWeight = Bold

End If
End Sub


Thanks,
 

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

Top