Setting the properties of "field1" based upon "field2" in a form

G

Guest

Hi guys,

I have a form with a "yes/no" field (field1) and a text field (field2). I
want to change the font and colour of field2 based upon if field1 is set to
yes or a different font and colour if field1 is set to no.

How do I do this?

Thanks for any helkp you can provide.

Regards
Greg
 
M

Marshall Barton

Lateral said:
I have a form with a "yes/no" field (field1) and a text field (field2). I
want to change the font and colour of field2 based upon if field1 is set to
yes or a different font and colour if field1 is set to no.


If the field is displayed in Single Form view, you can use
VBA code in both field1's AfterUpdate event and in the
form's Current event:

If Me.field1 = True Then
Me.field2.FontName = "Arial"
Me.field2.ForeColor = vbGreen
Else
Me.field2.FontName = "Wingdings"
Me.field2.ForeColor = RGB(255, 220,220) ' pink
End If

If your form is displayed in Continuous or Datasheet view,
then you can not change the font using standard features.
There are several properties you can control through the
Conditional Formatting feature. Click on field2, use Format
-Conditional Formatting menu item. Then select the
Expression Is: option and set the expression to:
[field1]
 
G

Guest

Hi Marshall,

I could not get this to work.

Marshall Barton said:
Lateral said:
I have a form with a "yes/no" field (field1) and a text field (field2). I
want to change the font and colour of field2 based upon if field1 is set to
yes or a different font and colour if field1 is set to no.


If the field is displayed in Single Form view, you can use
VBA code in both field1's AfterUpdate event and in the
form's Current event:

If Me.field1 = True Then
Me.field2.FontName = "Arial"
Me.field2.ForeColor = vbGreen
Else
Me.field2.FontName = "Wingdings"
Me.field2.ForeColor = RGB(255, 220,220) ' pink
End If

If your form is displayed in Continuous or Datasheet view,
then you can not change the font using standard features.
There are several properties you can control through the
Conditional Formatting feature. Click on field2, use Format
-Conditional Formatting menu item. Then select the
Expression Is: option and set the expression to:
[field1]
 
M

Marshall Barton

I wonder what you did that prevented you from getting it to
work.
--
Marsh
MVP [MS Access]

I could not get this to work.

Marshall Barton said:
Lateral said:
I have a form with a "yes/no" field (field1) and a text field (field2). I
want to change the font and colour of field2 based upon if field1 is set to
yes or a different font and colour if field1 is set to no.


If the field is displayed in Single Form view, you can use
VBA code in both field1's AfterUpdate event and in the
form's Current event:

If Me.field1 = True Then
Me.field2.FontName = "Arial"
Me.field2.ForeColor = vbGreen
Else
Me.field2.FontName = "Wingdings"
Me.field2.ForeColor = RGB(255, 220,220) ' pink
End If

If your form is displayed in Continuous or Datasheet view,
then you can not change the font using standard features.
There are several properties you can control through the
Conditional Formatting feature. Click on field2, use Format
-Conditional Formatting menu item. Then select the
Expression Is: option and set the expression to:
[field1]
 
G

Guest

:)

I will try again and let you know as it looks pretty straightforward.

Regards
Greg

Marshall Barton said:
I wonder what you did that prevented you from getting it to
work.
--
Marsh
MVP [MS Access]

I could not get this to work.

Marshall Barton said:
Lateral wrote:
I have a form with a "yes/no" field (field1) and a text field (field2). I
want to change the font and colour of field2 based upon if field1 is set to
yes or a different font and colour if field1 is set to no.


If the field is displayed in Single Form view, you can use
VBA code in both field1's AfterUpdate event and in the
form's Current event:

If Me.field1 = True Then
Me.field2.FontName = "Arial"
Me.field2.ForeColor = vbGreen
Else
Me.field2.FontName = "Wingdings"
Me.field2.ForeColor = RGB(255, 220,220) ' pink
End If

If your form is displayed in Continuous or Datasheet view,
then you can not change the font using standard features.
There are several properties you can control through the
Conditional Formatting feature. Click on field2, use Format
-Conditional Formatting menu item. Then select the
Expression Is: option and set the expression to:
[field1]
 

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