Manage Your Code
Snippet: HighlightRecord (VBA)
Title: HighlightRecord Language: VBA
Description: Highlight a record in Microsoft Access Views: 592
Author: Steve Moore Date Added: 4/16/2010
Copy Code  
1Function HighlightRecord(frm As Form, ctl As Control)
2Dim sName As String
3sName = ctl.Name
5frm.TextHighlight.ControlSource = _
6"=iif([" & sName & "]='" & ctl.Value & "','Yes','No')"
8End Function
1. Create an unbound text box (set it's visible property to 'No')
2. Name it 'TextHighlight'
3. Place above code in the Current event of a continuous form.
   Example: HighlightRecord Me, Me.ID
4. Apply conditional formatting based on 'TextHighlight' value
The value passed back to 'TextHighlight' is a 'Yes' if it is the current record, or a 'No' if it is not. This will ONLY work, if there is a unique identifier in the record (this function works whatever sort is applied to the recordset). So if you have an AutoNumber field, add this to the record (it can be invisible).