Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How format an entire row on a datasheet

Is there a way to conditionally format a whole row on a datasheet where "Tech" is the value of a field named TypeOfAppt? I want to make the back color yellow if TypeOfAppt is "Tech".
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

you can create a textbox which is the width of the form.  Place this behind all of the other controls, set it's TabStop property to No, and its background style to Normal.

Then using conditional formatting:

Select Expression
then in the expression use:

[TypeofAppt] = "Tech"

and set the background color to yellow.

Set the background style of all the other controls to transparent.

I also generally apply code to the GotFocus of the textbox, in the event that the user is able to set the cursor in that control, and simply set the focus to some other control on the form.
Avatar of SteveL13

ASKER

Dale,
Here's what I just did but it isn't working.

1) Created a new text box to lay under the other the other controls
2) Made it the width of the form.
3) Set the tabstop property to no.
4) Arranged it so it is behind the other controls and made backstyle normal.
5) Then in conditional formatting set the expression as [TypeofAppt] = "Tech" and set the background color to yellow.
6) Set the other controls to BackStyle = transparent.

What am I missing?
Are you sure that [TypeOfAppt] is actually a text field, and not a numeric value associated with a lookup table?  If the data type of the field in the actual table is numeric, then you need to test for the numeric value associated with "Tech", not the string.

Dale
It is definitely a text box.
I didn't ask if it was a text box, I asked what the DATA TYPE of the [TypeOfAppt] comment is.  Go to the table where this field is located, in design view, and look to see whether the field data type is numeric or text.

Go to the form where you enter this data, is it a textbox or a combo box?  If a combo, it is likely a numeric data type.

If it is a text entry, then you might have spaces or the spelling of "Tech" might be wrong.

Open the form in design view and get a screen shot.
Then select this background textbox and select conditional formatting, get a screen shot of that as well

Dale
ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good catch, John.  I missed the datasheet issue entirely.

Steve, in order to do this for a datasheet, you will have to set the conditional formatting of each of the controls and give them all a Normal background.
the problem with doing this in datasheets, is that each control, on every row has to be evaluated, and that can really slow the refresh rate down.

Dale
Understood.  Am going to abandon the background color issue.  I really want the form to be a datasheet
I have said many times that i dislike datasheet....take a look at this question and my screenshots :https://www.experts-exchange.com/questions/29161308/Unable-to-change-colour-of-Access-365-datasheet-column-heading-background.html
I love datasheets, but this is one of those places where a continuous form works better.

Dale
Datasheets and conditional formatting can have trouble getting the conditional formatting to display at times.
To do what you want to do, you'll have to use conditional formatting to set the backcolor of each control (not the control's label) on your datasheet.
Use the Expression condition and set:
[TypeOfAppt] = "Tech"
to make the backcolor yellow.  No promises or how well it all works together.