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

conditional formatting of textbox

P: n/a
Thanks in advance... I have a continuous style form with a field for
each record called "STATUS". I simply want to have the form load and
if the value of the textbox is "Inactive" I want the textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working

Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
Me!STATUS.BackColor = RGB(255, 255, 255)
End If
End Sub
'Thanks!

May 29 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 29, 1:48 pm, slinky <campbellbrian2...@yahoo.comwrote:
Thanks in advance... I have a continuous style form with a field for
each record called "STATUS". I simply want to have the form load and
if the value of the textbox is "Inactive" I want the textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working

Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
Me!STATUS.BackColor = RGB(255, 255, 255)
End If
End Sub

'Thanks!
http://www.mvps.org/access/forms/frm0047.htm

May 29 '07 #2

P: n/a
On 29 May 2007 10:48:33 -0700, slinky wrote:
Thanks in advance... I have a continuous style form with a field for
each record called "STATUS". I simply want to have the form load and
if the value of the textbox is "Inactive" I want the textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working

Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
Me!STATUS.BackColor = RGB(255, 255, 255)
End If
End Sub

'Thanks!
Use Conditional formatting (Access 2000 or newer).
In Form Design view, right-click on the [Status] control and select
Conditional formatting.
Set the Condition1 drop-down to Field Value Is.
Select "equal to" in the next drop-down box
Write "Inactive"
in the next box.
Select the BackColor.
Save the changes.

Note: the above assumes the datatype of the [Status] control is Text.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 29 '07 #3

P: n/a
On May 29, 11:04 pm, fredg <fgutk...@example.invalidwrote:
On 29 May 2007 10:48:33 -0700, slinky wrote:
Thanks in advance... I have a continuous style form with a field for
each record called "STATUS". I simply want to have the form load and
if the value of the textbox is "Inactive" I want the textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working
Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
Me!STATUS.BackColor = RGB(255, 255, 255)
End If
End Sub
'Thanks!

Use Conditional formatting (Access 2000 or newer).
In Form Design view, right-click on the [Status] control and select
Conditional formatting.
Set the Condition1 drop-down to Field Value Is.
Select "equal to" in the next drop-down box
Write "Inactive"
in the next box.
Select the BackColor.
Save the changes.

Note: the above assumes the datatype of the [Status] control is Text.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Hi Fred,

Any idea why this does not work for multi-valued combo box? i.e. if
above formating is used, it works only if that single value is
selected. If multiple values are selected with that value, it does not
work.

May 30 '07 #4

P: n/a
On 29 May 2007 22:48:09 -0700, Matuag wrote:
On May 29, 11:04 pm, fredg <fgutk...@example.invalidwrote:
>On 29 May 2007 10:48:33 -0700, slinky wrote:
>>Thanks in advance... I have a continuous style form with a field for
each record called "STATUS". I simply want to have the form load and
if the value of the textbox is "Inactive" I want the textbox
background to display yellow, else I want it to be just white. Here's
my code... but it is not working
>>Private Sub Form_Load()
If Me!STATUS = "Inactive" Then
Me!STATUS.BackColor = RGB(255, 255, 0)
Else
Me!STATUS.BackColor = RGB(255, 255, 255)
End If
End Sub
>>'Thanks!

Use Conditional formatting (Access 2000 or newer).
In Form Design view, right-click on the [Status] control and select
Conditional formatting.
Set the Condition1 drop-down to Field Value Is.
Select "equal to" in the next drop-down box
Write "Inactive"
in the next box.
Select the BackColor.
Save the changes.

Note: the above assumes the datatype of the [Status] control is Text.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Hi Fred,

Any idea why this does not work for multi-valued combo box? i.e. if
above formating is used, it works only if that single value is
selected. If multiple values are selected with that value, it does not
work.
1) A combo Box cannot contain multiple values. Perhaps you meant to
say a List Box.

2) Well if you select "x" and "y" and "z" in a list box, then it's
value is xyz, not just x.

3) To work with a multi-select list box you'll need to use code to
cycle through the selections and do something with them. There is
sample code in VBA help to do this.

4) Why didn't you state, in your original post, that it was a
multi-select list box?


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 30 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.