Draneer Code Library

Making report detail rows alternate between white and grey background.
Use this instead of putting boxes around all the fields (which is too cluttered looking).

Typical Usage:
 - [txtBack] is an empty text control sitting behind all the TRANSPARENT data controls. This method suffers when data controls GROW out of the txtBack bounds!
 - Replace [txtBack] with object Me.Section("Detail") to have the Can Grow fields always correctly backgrounded.

Module Code
=========================================================================================================
Option Explicit
Dim lngC As Long '-- Grey [backcolor] - Module Variable.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  '-- Switch txtBack colour alternately.
  With [txtBack]
    If .BackColor = vbWhite Then
      .BackColor = lngC
    Else
      .BackColor = vbWhite
    End If
  End With
End Sub

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
  '---- Reset starting record back colour.
  [txtBack].BackColor = vbWhite
End Sub

Private Sub Report_Load()
  '---- Set the alternate colour for the background.
  lngC = RGB(&HEA, &HEA, &HEA) '-- Grey
End Sub

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
  Dim sec As Section
  '---- Get criteria from the browser.
  Set frm = Forms![frmBrowseTimesheets]
  Set sec = frm.Section("FormHeader")
  '---- Loop all "Find" criteria boxes in the form.
  For Each ctrl In sec.Controls
    If ctrl.Tag = "Find" Then
    Me(ctrl.Name) = ctrl.Value
    End If
  Next ctrl
End Sub

 

 

Back to ...
Code Library Menu