Highlight the Current Row

Using a continuous form, Conditional Formatting and VBA, we can easily give a visual indicator of the currently selected row. This example sets the ID field as Bold for the current row, but this can be applied to multiple controls. A common approach is to make a textbox that fills the background of the continuous form, bring all of the other controls on top and set their backgrounds to transparent so the underlying “coverage” control shows through, then just highlight that control.

Use the Current event to remove existing FormatConditions then create a new FormatCondition based on the current record’s ID and apply it to the control:

Private Sub Form_Current()
  
  Dim fc As FormatCondition
  
  With Me.ctlTargetControl
    While .FormatConditions.count > 0
      .FormatConditions.Delete
    Wend
    Set fc = .FormatConditions.Add(acExpression, acEqual, "[ID] = " & Me.ID)
    fc.FontBold = True
  End With
  
End Sub

That’s it!

Share on:

Recent articles

Third-Party Integrations

Third-party integrations offer benefits in terms of functionality and efficiency, but they also carry security considerations and other drawbacks. If you’re currently using third-party applications

Read More >