Access MVP (2010-2015)

oOo.oOo.oOo.oOo.oOo.oOo

Highlight Current Record…

Highlighting the current record is an often asked question.  You could use Conditional Formatting but then you have to do it for each Control in the Detail section of your Form.  I prefer this way…

Step 1

Make sure all visible controls have been set for a Transparent background

Step 2

Put an invisible Control in the Form’s Header, in this example it’s named txtHighlightID and put the Primary Key in the Detail section and make that Control invisible also, in this example it’s named txtID.

Step 3

In the Forms (yes, also works on Subforms) On_Current event put…

Me.txtHighlightID = Me.txtID

Step 4

Put a Control, it’s named txtHighlight in this example, that spans the full width of the Form…

=IIf([txtID]=[txtHighlightID],"█████████████████████████████████████████████████████████████████████████████████████████████████████████████","")

Set the Font Size to insure it goes the Height of the Row and select the color of the Font for your Control (this is what determines the color of the highlighting).  In this example I used #F6FBDD.  Make sure to go the Arrange tab, click on txtHighlight and click Send to Back.  For how to get the Full Block that is the highlight, see Conditional Row Shading on a Continuous Form.

Neaten up your Form and then preview… when you click on a row it will now highlight.  You can download a sample here.

 2,036 total views,  2 views today

Comments are closed.