Conditional formatting of a subform's background color

  • Thread starter Nicholas Scarpinato
  • Start date
N

Nicholas Scarpinato

I've read about 50 examples of how to use Conditional Formatting to change
the color of specific fields in a continuous form. Is there a way to use it
to change the form's background color for that particular record, while
leaving the records that are have not met the condition in their normal
format? What I'm attempting to do is build a form that shows all of the users
who are out on break, with their "Out" time and their "Due In" time. I want
to display the users who have not passed their "Due In" with a green
background, and the ones who have passed that time with a red background. I
can get one or the other, but it all depends on the first record in the form.
If the first record in the form meets the "lapsed" criteria, the entire
subform displays with the red background, and vice versa. Can this be done
with a continuous form, or do I need to look into another way to attempt this?

Here is my code... part of my problem is I'm not real sure where to put this
code so that it runs on every record, or if I've even got it written
correctly:

If DateDiff("m", Me!DueTime, Now()) > 15 Then
PastClockTime = 1
Else
PastClockTime = 2
End If
Select Case PastClockTime
Case 1
Me.Detail.BackColor = 1643706
Me.Label1.ForeColor = 16777215
Me.Label3.ForeColor = 16777215
Me.Label5.ForeColor = 16777215
Me.Label7.ForeColor = 16777215
Case 2
Me.Detail.BackColor = 16777215
Me.Label1.ForeColor = 0
Me.Label3.ForeColor = 0
Me.Label5.ForeColor = 0
Me.Label7.ForeColor = 0
End Select


Any help is much appreciated. Thanks!
 
A

Al Campagna

Nicholas,
If you can make your subform controls transparent, you can use an
unbound text control behind your fields, and apply ConditionalFormatting to
that.
Make the "background" text contol as high and as wide as your subform
detail record.
Cond/Formatting that background control will make the backgrounds of all
your transparent fields "appear" to correctly colored.
Condition1
Expression Is [PastClockTime] = 1
Condition2
Expression Is [PastClockTime] = 2
hth
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

Nicholas Scarpinato

That's an interesting way to do it... I'll try that. Thanks!

Al Campagna said:
Nicholas,
If you can make your subform controls transparent, you can use an
unbound text control behind your fields, and apply ConditionalFormatting to
that.
Make the "background" text contol as high and as wide as your subform
detail record.
Cond/Formatting that background control will make the backgrounds of all
your transparent fields "appear" to correctly colored.
Condition1
Expression Is [PastClockTime] = 1
Condition2
Expression Is [PastClockTime] = 2
hth
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Nicholas Scarpinato said:
I've read about 50 examples of how to use Conditional Formatting to change
the color of specific fields in a continuous form. Is there a way to use
it
to change the form's background color for that particular record, while
leaving the records that are have not met the condition in their normal
format? What I'm attempting to do is build a form that shows all of the
users
who are out on break, with their "Out" time and their "Due In" time. I
want
to display the users who have not passed their "Due In" with a green
background, and the ones who have passed that time with a red background.
I
can get one or the other, but it all depends on the first record in the
form.
If the first record in the form meets the "lapsed" criteria, the entire
subform displays with the red background, and vice versa. Can this be done
with a continuous form, or do I need to look into another way to attempt
this?

Here is my code... part of my problem is I'm not real sure where to put
this
code so that it runs on every record, or if I've even got it written
correctly:

If DateDiff("m", Me!DueTime, Now()) > 15 Then
PastClockTime = 1
Else
PastClockTime = 2
End If
Select Case PastClockTime
Case 1
Me.Detail.BackColor = 1643706
Me.Label1.ForeColor = 16777215
Me.Label3.ForeColor = 16777215
Me.Label5.ForeColor = 16777215
Me.Label7.ForeColor = 16777215
Case 2
Me.Detail.BackColor = 16777215
Me.Label1.ForeColor = 0
Me.Label3.ForeColor = 0
Me.Label5.ForeColor = 0
Me.Label7.ForeColor = 0
End Select


Any help is much appreciated. Thanks!
 
A

Al Campagna

Let me know how you make out...

Nicholas Scarpinato said:
That's an interesting way to do it... I'll try that. Thanks!

Al Campagna said:
Nicholas,
If you can make your subform controls transparent, you can use an
unbound text control behind your fields, and apply ConditionalFormatting
to
that.
Make the "background" text contol as high and as wide as your subform
detail record.
Cond/Formatting that background control will make the backgrounds of
all
your transparent fields "appear" to correctly colored.
Condition1
Expression Is [PastClockTime] = 1
Condition2
Expression Is [PastClockTime] = 2
hth
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

"Nicholas Scarpinato" <[email protected]>
wrote
in message news:[email protected]...
I've read about 50 examples of how to use Conditional Formatting to
change
the color of specific fields in a continuous form. Is there a way to
use
it
to change the form's background color for that particular record, while
leaving the records that are have not met the condition in their normal
format? What I'm attempting to do is build a form that shows all of the
users
who are out on break, with their "Out" time and their "Due In" time. I
want
to display the users who have not passed their "Due In" with a green
background, and the ones who have passed that time with a red
background.
I
can get one or the other, but it all depends on the first record in the
form.
If the first record in the form meets the "lapsed" criteria, the entire
subform displays with the red background, and vice versa. Can this be
done
with a continuous form, or do I need to look into another way to
attempt
this?

Here is my code... part of my problem is I'm not real sure where to put
this
code so that it runs on every record, or if I've even got it written
correctly:

If DateDiff("m", Me!DueTime, Now()) > 15 Then
PastClockTime = 1
Else
PastClockTime = 2
End If
Select Case PastClockTime
Case 1
Me.Detail.BackColor = 1643706
Me.Label1.ForeColor = 16777215
Me.Label3.ForeColor = 16777215
Me.Label5.ForeColor = 16777215
Me.Label7.ForeColor = 16777215
Case 2
Me.Detail.BackColor = 16777215
Me.Label1.ForeColor = 0
Me.Label3.ForeColor = 0
Me.Label5.ForeColor = 0
Me.Label7.ForeColor = 0
End Select


Any help is much appreciated. Thanks!
 
A

Al Campagna

It's not fancy, but should do the trick...
Let me know how you make out.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Nicholas Scarpinato said:
That's an interesting way to do it... I'll try that. Thanks!

Al Campagna said:
Nicholas,
If you can make your subform controls transparent, you can use an
unbound text control behind your fields, and apply ConditionalFormatting
to
that.
Make the "background" text contol as high and as wide as your subform
detail record.
Cond/Formatting that background control will make the backgrounds of
all
your transparent fields "appear" to correctly colored.
Condition1
Expression Is [PastClockTime] = 1
Condition2
Expression Is [PastClockTime] = 2
hth
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your
life."

"Nicholas Scarpinato" <[email protected]>
wrote
in message news:[email protected]...
I've read about 50 examples of how to use Conditional Formatting to
change
the color of specific fields in a continuous form. Is there a way to
use
it
to change the form's background color for that particular record, while
leaving the records that are have not met the condition in their normal
format? What I'm attempting to do is build a form that shows all of the
users
who are out on break, with their "Out" time and their "Due In" time. I
want
to display the users who have not passed their "Due In" with a green
background, and the ones who have passed that time with a red
background.
I
can get one or the other, but it all depends on the first record in the
form.
If the first record in the form meets the "lapsed" criteria, the entire
subform displays with the red background, and vice versa. Can this be
done
with a continuous form, or do I need to look into another way to
attempt
this?

Here is my code... part of my problem is I'm not real sure where to put
this
code so that it runs on every record, or if I've even got it written
correctly:

If DateDiff("m", Me!DueTime, Now()) > 15 Then
PastClockTime = 1
Else
PastClockTime = 2
End If
Select Case PastClockTime
Case 1
Me.Detail.BackColor = 1643706
Me.Label1.ForeColor = 16777215
Me.Label3.ForeColor = 16777215
Me.Label5.ForeColor = 16777215
Me.Label7.ForeColor = 16777215
Case 2
Me.Detail.BackColor = 16777215
Me.Label1.ForeColor = 0
Me.Label3.ForeColor = 0
Me.Label5.ForeColor = 0
Me.Label7.ForeColor = 0
End Select


Any help is much appreciated. 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