I frequently use side-by-side datasheets, where clicking on a record on left one displays related detail in the left. When moving from tab to tab on a form, however, sometimes it is not immediately evident which record on left has been selected. So I wanted to highlight it. I've done this on continuous forms, but until now I couldn't do it for a datasheet.
The technique is very simple. Let's assume the recordsource for your "left" datasheet has a field named CustomerID, and that it is the unique record identifier. Put a textbox in the form's header, and name it [txtRecordID]. In the current event of your form, you need this line of code:
txtRecordID = Me.CustomerID[/code]
Then you need to add a Conditional Format to each control on the datasheet. You can select all the controls at once and enter this:
Expression Is [CustomerID]=[txtRecordID]
Then, select a different BackColor.
Highlighting the current row in a Datasheet
-
- 3StarLounger
- Posts: 331
- Joined: 11 Feb 2010, 03:55
- Location: Land O Lakes, FL
Highlighting the current row in a Datasheet
Mark Liquorman
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.
-
- Administrator
- Posts: 78790
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 3StarLounger
- Posts: 287
- Joined: 09 Mar 2010, 23:16
- Location: Canberra Australia
Re: Highlighting the current row in a Datasheet
I was doing something similar yesterday with a Continuous Form.
It was a while since I had done this, so I needed to remember just what to do. In my first attempt, I just set the Control Source of the control in the Header to: =me.ChildID. Sure enough it displayed the correct ID as I moved between records, but the conditional formatting did not work. (All rows displayed the conditional format.)
But once I set the value in the On Current event (as Mark suggests) it did work.
Why does it not work using the first method?
It was a while since I had done this, so I needed to remember just what to do. In my first attempt, I just set the Control Source of the control in the Header to: =me.ChildID. Sure enough it displayed the correct ID as I moved between records, but the conditional formatting did not work. (All rows displayed the conditional format.)
But once I set the value in the On Current event (as Mark suggests) it did work.
Why does it not work using the first method?
Regards
John
John
-
- Administrator
- Posts: 78790
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Highlighting the current row in a Datasheet
It might be a timing problem, but that's just a guess. I don't know for sure.JohnH wrote:Why does it not work using the first method?
Best wishes,
Hans
Hans