PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting vs. Code for Highlighting/backcolor questio

 
 
ThriftyFinanceGirl
Guest
Posts: n/a
 
      21st Sep 2009
How can I get an entire row to highlight instead of just one field?
 
Reply With Quote
 
 
 
 
David H
Guest
Posts: n/a
 
      21st Sep 2009
Haven't played with that, but try using the .BackColor property as in...

[Forms]![FormName]![DetailSectionName].BackColor

or

[Forms]![FormName]![SubFormName].subform![DetailSectionName].BackColor

The Header, Detail, and Footer sections of a form are controls just like any
other. Typically, the .Name property will default to 'Header', 'Detail',
'Footer'.

If that doesn't work, you can add an unbound field that covers the entire
detail section and add Conditional Formatting to that. Just be certain that
you ensure that it isn't set as a TabStop. You'll may also want to add code
to its onGotFocus event to move the cursor to an actual field as a cosmetic
touch to avoid the user's complaining about 'Where's the cursor'.

[Forms]![FormName]![DestinationControlName].SetFocus

"ThriftyFinanceGirl" wrote:

> How can I get an entire row to highlight instead of just one field?

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      21st Sep 2009
Need to be a little more specific.

What version of Access are you using? If A2007, then the details section of
both reports and forms contain a "Alternate Back Color" property. Just set
the color of this property to achieve your goal.

If you are using an earlier version of Access, it becomes a little more
difficult (at least I don't remember earlier versions containing this
property). If you have a field in your forms RecordSource (table or query)
which contains a sequential numeric value (you could call this a row number),
then you could:
1. Create an unbound textbox and size it to span the entire width and
height of the detail section.
2. You will then have to move it to the background (I think 2003 has this
ability) by right clicking on the textbox and selecting - Position -> Send to
Back from the popup menu. You may also have to select each of the other
controls and bring them to the front.
3. Then set its Tab Stop property to No
4. In the controls GotFocus event, set the focus to one of the other
controls in the details section of the form.
5. Finally, set the conditional formatting for that text box so that the
condition is based on an expression. The expression will look something like:

Same technique will work for a report, although you won't have to do steps 3
and 4 in a report. Another method in a report would be to use the Format
event of the detail section. Add the following code to that event to get
alternate color backgrounds.


Static RowCount As Long

RowCount = RowCount + 1
Me.Section(acDetail).BackColor = IIf(RowCount Mod 2 = 0, RGB(255, 255,
255), RGB(236, 250, 252))


----
HTH
Dale



"ThriftyFinanceGirl" wrote:

> How can I get an entire row to highlight instead of just one field?

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      21st Sep 2009
ThriftyFinanceGirl wrote:

>How can I get an entire row to highlight instead of just one field?


A single row in a form? Can't be done for a form in
datasheet view.

For a continuous form, use a large text box as Dale
described. An alternative to Dale's steps 2, 3 and 4 is to
set the large text box's Locked property to Yes and Enabled
property to No.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      21st Sep 2009
But if you disable it, it changes the color by subduing it.

----
HTH
Dale



"Marshall Barton" wrote:

> ThriftyFinanceGirl wrote:
>
> >How can I get an entire row to highlight instead of just one field?

>
> A single row in a form? Can't be done for a form in
> datasheet view.
>
> For a continuous form, use a large text box as Dale
> described. An alternative to Dale's steps 2, 3 and 4 is to
> set the large text box's Locked property to Yes and Enabled
> property to No.
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
ThriftyFinanceGirl
Guest
Posts: n/a
 
      21st Sep 2009
Using 2003, they haven't upgraded here yet. However, I think I can use the
box in the background. However, using conditional formatting you can set a
field that has focus in a datasheet a certain backcolor. Then you could set
the other fields with a conditional formatting also? But it would have to be
an expression. I guess that is what you guys are all saying can't be done?

"Dale Fye" wrote:

> Need to be a little more specific.
>
> What version of Access are you using? If A2007, then the details section of
> both reports and forms contain a "Alternate Back Color" property. Just set
> the color of this property to achieve your goal.
>
> If you are using an earlier version of Access, it becomes a little more
> difficult (at least I don't remember earlier versions containing this
> property). If you have a field in your forms RecordSource (table or query)
> which contains a sequential numeric value (you could call this a row number),
> then you could:
> 1. Create an unbound textbox and size it to span the entire width and
> height of the detail section.
> 2. You will then have to move it to the background (I think 2003 has this
> ability) by right clicking on the textbox and selecting - Position -> Send to
> Back from the popup menu. You may also have to select each of the other
> controls and bring them to the front.
> 3. Then set its Tab Stop property to No
> 4. In the controls GotFocus event, set the focus to one of the other
> controls in the details section of the form.
> 5. Finally, set the conditional formatting for that text box so that the
> condition is based on an expression. The expression will look something like:
>
> Same technique will work for a report, although you won't have to do steps 3
> and 4 in a report. Another method in a report would be to use the Format
> event of the detail section. Add the following code to that event to get
> alternate color backgrounds.
>
>
> Static RowCount As Long
>
> RowCount = RowCount + 1
> Me.Section(acDetail).BackColor = IIf(RowCount Mod 2 = 0, RGB(255, 255,
> 255), RGB(236, 250, 252))
>
>
> ----
> HTH
> Dale
>
>
>
> "ThriftyFinanceGirl" wrote:
>
> > How can I get an entire row to highlight instead of just one field?

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      21st Sep 2009
I would use an expression for the background color.

You don't want the unbound control to get the focus, that is the reason for
the code in the GotFocus event. Marshall's idea of disabling the control is
really a pretty good one. You could give the set the controls backcolor
using conditional formatting, and then when you disable it, that will make it
a little duller color. But overall a pretty good idea.

The challenge will be the sequentially numbered field. Autonumber fields do
not guarantee that they will be generated sequentially, and even if they did,
that doesn't account for records that get deleted. So in order for this
method to work, you will need to add another field (long integer) to your
underlying recordset which you could update before opening the form, OR, you
would have to add a column to your record sources query, something like:

SeqNumber: (SELECT Count(*) FROM yourTable as T WHERE T.[PKField] < =
yourTable.[PKField])

The problem with either of these is that they could be time consuming, and
neither one will work if you filter the form after loading the recordset.

----
HTH
Dale



"ThriftyFinanceGirl" wrote:

> Using 2003, they haven't upgraded here yet. However, I think I can use the
> box in the background. However, using conditional formatting you can set a
> field that has focus in a datasheet a certain backcolor. Then you could set
> the other fields with a conditional formatting also? But it would have to be
> an expression. I guess that is what you guys are all saying can't be done?
>
> "Dale Fye" wrote:
>
> > Need to be a little more specific.
> >
> > What version of Access are you using? If A2007, then the details section of
> > both reports and forms contain a "Alternate Back Color" property. Just set
> > the color of this property to achieve your goal.
> >
> > If you are using an earlier version of Access, it becomes a little more
> > difficult (at least I don't remember earlier versions containing this
> > property). If you have a field in your forms RecordSource (table or query)
> > which contains a sequential numeric value (you could call this a row number),
> > then you could:
> > 1. Create an unbound textbox and size it to span the entire width and
> > height of the detail section.
> > 2. You will then have to move it to the background (I think 2003 has this
> > ability) by right clicking on the textbox and selecting - Position -> Send to
> > Back from the popup menu. You may also have to select each of the other
> > controls and bring them to the front.
> > 3. Then set its Tab Stop property to No
> > 4. In the controls GotFocus event, set the focus to one of the other
> > controls in the details section of the form.
> > 5. Finally, set the conditional formatting for that text box so that the
> > condition is based on an expression. The expression will look something like:
> >
> > Same technique will work for a report, although you won't have to do steps 3
> > and 4 in a report. Another method in a report would be to use the Format
> > event of the detail section. Add the following code to that event to get
> > alternate color backgrounds.
> >
> >
> > Static RowCount As Long
> >
> > RowCount = RowCount + 1
> > Me.Section(acDetail).BackColor = IIf(RowCount Mod 2 = 0, RGB(255, 255,
> > 255), RGB(236, 250, 252))
> >
> >
> > ----
> > HTH
> > Dale
> >
> >
> >
> > "ThriftyFinanceGirl" wrote:
> >
> > > How can I get an entire row to highlight instead of just one field?

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      21st Sep 2009
Not if it is also Locked.
--
Marsh
MVP [MS Access]


Dale Fye wrote:
>But if you disable it, it changes the color by subduing it.
>
>
>"Marshall Barton" wrote:
>
>> ThriftyFinanceGirl wrote:
>>
>> >How can I get an entire row to highlight instead of just one field?

>>
>> A single row in a form? Can't be done for a form in
>> datasheet view.
>>
>> For a continuous form, use a large text box as Dale
>> described. An alternative to Dale's steps 2, 3 and 4 is to
>> set the large text box's Locked property to Yes and Enabled
>> property to No.

 
Reply With Quote
 
Dale Fye
Guest
Posts: n/a
 
      21st Sep 2009
Hmmm!

I never noticed that before. Learn something new every day!

----
Dale



"Marshall Barton" wrote:

> Not if it is also Locked.
> --
> Marsh
> MVP [MS Access]
>
>
> Dale Fye wrote:
> >But if you disable it, it changes the color by subduing it.
> >
> >
> >"Marshall Barton" wrote:
> >
> >> ThriftyFinanceGirl wrote:
> >>
> >> >How can I get an entire row to highlight instead of just one field?
> >>
> >> A single row in a form? Can't be done for a form in
> >> datasheet view.
> >>
> >> For a continuous form, use a large text box as Dale
> >> described. An alternative to Dale's steps 2, 3 and 4 is to
> >> set the large text box's Locked property to Yes and Enabled
> >> property to No.

>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      21st Sep 2009
Dale Fye wrote:

>Hmmm!
>
>I never noticed that before. Learn something new every day!
>


And that's what makes all this so much fun ;-)

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting: Change .BackColor on-the-fly? PeteCresswell Microsoft Access 2 18th Mar 2008 09:01 PM
Highlighting using Conditional Formatting =?Utf-8?B?U0xXNjEy?= Microsoft Excel Worksheet Functions 3 13th Mar 2007 10:04 PM
Conditional formatting - Highlighting a row =?Utf-8?B?Q29jbw==?= Microsoft Excel Worksheet Functions 6 24th Feb 2007 08:58 PM
Conditional formatting and row highlighting Cary Microsoft Excel Discussion 3 3rd Jun 2005 04:35 PM
Conditional Formatting: Custom BackColor =?Utf-8?B?VG9tVA==?= Microsoft Access Forms 4 22nd Nov 2004 10:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 PM.