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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight selected row on datasheet 1

Status
Not open for further replies.

thames11

Technical User
Feb 10, 2007
7
GB
Hi,

I have a datasheet and when a row is selected (or any field within that row) would like the row's background color to change. Thus highlighting the selected row.

What is the simplest way of achieving this, please?

Many thanks.

Simon.
 
I have never tried this on a datasheet, and I'm not sure you can do it. (Datasheets have limited capabilities.)

If, however, your form is a continuos form instead, you could add an unbound text box that frames all your fields. Be sure to "send it to back" using the format menu. All your controls will then need to have their backgrounds set to transparent.

Then on the "on click" event of all your controls, you will need something like this:

me.unboundcontrolname.backgroundcolor = integervalue

I don't remember if background color is the exact name of the property, but you can check that easily. You will need to look up the integer values for the color you want. (for instance, 0 is black.)

Hope that helps.
 
Thanks to all,

Ray Vidar's solution looks simplest.
thread702-958217

But I get stuck when he says:

In the on current event of the form, assign a unique value of the form to the text control (primary key, let's say txtID).

Can anyone please clarify what I need to do?

Thanks.
 
Put a textbox in the header of the continuous form and add some code to the current event of this form. Say:

Code:
Private Sub Form_Current()
Me.txtTest = Me.ID  'ID is the primary key for the form.
End Sub

Follow on with assigning the conditional formatting. Make sure you use square brackets.
 
Well ... thanks, but it is all Roy Vidar's work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top