Conditional Formatting on a Continuous Form

J

JamesJ

Hi. I have 4 text boxes occupying the row on a continuous form.
Reminder, ReminderDate, ReminderTime and ReminderTypeID.
The value of ReminderTypeID field is either 1, 2 or 3. I would like
to have the entire row's BackColor and ForeColor set depending
on the value of the ReminderID field. In other words there will be
3 different BackColors for each text box.I tried setting the colors
in the OnCurrent of the form using the following code for just 1 field
but the BackColor gets changed for each record. Not even sure if the
code is in the correct event.

Private Sub Form_Current()

If Me!ReminderTypeID.Value = 1 Then
Me!Reminder.BackColor = vbRed
Me!Reminder.ForeColor = vbWhite

End If

End Sub

Any help will be appreciated as always,
James
 
F

fredg

Hi. I have 4 text boxes occupying the row on a continuous form.
Reminder, ReminderDate, ReminderTime and ReminderTypeID.
The value of ReminderTypeID field is either 1, 2 or 3. I would like
to have the entire row's BackColor and ForeColor set depending
on the value of the ReminderID field. In other words there will be
3 different BackColors for each text box.I tried setting the colors
in the OnCurrent of the form using the following code for just 1 field
but the BackColor gets changed for each record. Not even sure if the
code is in the correct event.

Private Sub Form_Current()

If Me!ReminderTypeID.Value = 1 Then
Me!Reminder.BackColor = vbRed
Me!Reminder.ForeColor = vbWhite

End If

End Sub

Any help will be appreciated as always,
James

You'll not be able to do this on a continuous form using VBA, however
if you have Access 2000 or newer you can use the control's Conditional
Formatting property.
In Form Design View:
Select the [Reminder] control.
Click on Format + Conditional Formatting.
Set the Condition1 drop down to
Expression Is
In the next box write:
[ReminderTypeID] = 1
Set the Fore and back colors to whatever you want.
Click on Add>>.
Do the same for Condition2 and 3, setting the expression to the
[ReminderTypeID] value of 2 or 3 respectively.
 
F

fredg

Hi. I have 4 text boxes occupying the row on a continuous form.
Reminder, ReminderDate, ReminderTime and ReminderTypeID.
The value of ReminderTypeID field is either 1, 2 or 3. I would like
to have the entire row's BackColor and ForeColor set depending
on the value of the ReminderID field. In other words there will be
3 different BackColors for each text box.I tried setting the colors
in the OnCurrent of the form using the following code for just 1 field
but the BackColor gets changed for each record. Not even sure if the
code is in the correct event.

Private Sub Form_Current()

If Me!ReminderTypeID.Value = 1 Then
Me!Reminder.BackColor = vbRed
Me!Reminder.ForeColor = vbWhite

End If

End Sub

Any help will be appreciated as always,
James

You'll not be able to do this on a continuous form using VBA, however
if you have Access 2000 or newer you can use the control's Conditional
Formatting property.
In Form Design View:
Select the [Reminder] control.
Click on Format + Conditional Formatting.
Set the Condition1 drop down to
Expression Is
In the next box write:
[ReminderTypeID] = 1
Set the Fore and back colors to whatever you want.
Click on Add>>.
Do the same for Condition2 and 3, setting the expression to the
[ReminderTypeID] value of 2 or 3 respectively.

Sorry, I misread your question.
I told you how to get 3 different colors in one control using 3
different conditions.
Use the same information as I gave you but there is only one condition
in a control, not 3. Do the same for each of the 4 controls.
 
J

JamesJ

It works fine now! Thanks much.

Thanks again,
James

fredg said:
Hi. I have 4 text boxes occupying the row on a continuous form.
Reminder, ReminderDate, ReminderTime and ReminderTypeID.
The value of ReminderTypeID field is either 1, 2 or 3. I would like
to have the entire row's BackColor and ForeColor set depending
on the value of the ReminderID field. In other words there will be
3 different BackColors for each text box.I tried setting the colors
in the OnCurrent of the form using the following code for just 1 field
but the BackColor gets changed for each record. Not even sure if the
code is in the correct event.

Private Sub Form_Current()

If Me!ReminderTypeID.Value = 1 Then
Me!Reminder.BackColor = vbRed
Me!Reminder.ForeColor = vbWhite

End If

End Sub

Any help will be appreciated as always,
James

You'll not be able to do this on a continuous form using VBA, however
if you have Access 2000 or newer you can use the control's Conditional
Formatting property.
In Form Design View:
Select the [Reminder] control.
Click on Format + Conditional Formatting.
Set the Condition1 drop down to
Expression Is
In the next box write:
[ReminderTypeID] = 1
Set the Fore and back colors to whatever you want.
Click on Add>>.
Do the same for Condition2 and 3, setting the expression to the
[ReminderTypeID] value of 2 or 3 respectively.

Sorry, I misread your question.
I told you how to get 3 different colors in one control using 3
different conditions.
Use the same information as I gave you but there is only one condition
in a control, not 3. Do the same for each of the 4 controls.
 

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