Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change colour of selected row in datasheet subform 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
0
0
GB

Is it possible to change the colour of the selected row of a datasheet subform? On opening a form the top row of the subform is quite a dark blue, which is distracting on some forms.

I've seen various suggestions about adding an unbound field the size of the Detail section, then using Conditional Formatting. But this seems long winded with a large number of forms to do. I also didn't get it to work.
 
Without field names consider an employee subform with a primary key EmployeeID.

I would add a text box in the datasheet's header section name txtEmpID. Add code in the On Current event of the datasheet subform:

Code:
Private Sub Form_Current()
    Me.txtEmpID = Me.EmployeeID
End Sub

Then select all of the text boxes in the datasheet subform and set conditional formatting.

Expression Is: [txtEmpID]=[EmployeeID]

Set the format as desired.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Hi Duane, and thanks as ever.

This is very nearly there. I get this appearance and can't see what causes the light blue vertical borders, which look bold. Nor the red horizontal lines that appear on selecting a row.

First_row_a1kmug.jpg


The equivalent of txtEmpID has white back colour and border set to black, solid, 1 pt. The Form Header back colour is white.
 
I'm not sure what is what. You suggest the "Form Header back colour is white" however nothing in your form header is white that I can see. Do you have any code or conditional formatting set?

I get a red border around the entire record in the datasheet subform when the record is selected or around the control when it has the focus. This is a datasheet view attribute. The current row also has a blue background by default in datasheet view.

If you don't like these formats you could make a continuous form. You might also check Use WIndows-themed Controls on Forms in the Access Current Database Options.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Sorry, I meant the subform's header.

I used just the conditional formatting you suggested, nowhere else.

Thanks for your help again, and other suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top