Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim lngBkColor As Long
Dim Idx As Integer
Dim strCtrlNames() As String
Dim intCtrlPos() As Long
Dim tmpName As String
Dim tmpPos As Long
Dim Sorted As Boolean
Dim blnFstPass As Boolean
Dim MyCtrl As String
Dim intCtrlCnt As Integer
Dim MaxCtrl As Control
intCtrlCnt = Me.Section(0).Controls.Count
ReDim strCtrlNames(intCtrlCnt)
ReDim intCtrlPos(intCtrlCnt)
lngBkColor = RGB(190, 190, 190) '12632256
While Idx < intCtrlCnt
strCtrlNames(Idx) = Me.Section(0).Controls(Idx).name
intCtrlPos(Idx) = Me.Section(0).Controls(Idx).Left
If (Me.Section(0).Controls(Idx).height > MaxHt) Then
MaxHt = Me.Section(0).Controls(Idx).height
End If
Idx = Idx + 1
Wend
'Sort the Names according to the Position
Idx = 0
Sorted = False
While Sorted = False
Sorted = True
While Idx < intCtrlCnt - 1
If (intCtrlPos(Idx) > intCtrlPos(Idx + 1)) Then
Sorted = False
tmpCtrlPos = intCtrlPos(Idx)
tmpCtrlName = strCtrlNames(Idx)
intCtrlPos(Idx) = intCtrlPos(Idx + 1)
strCtrlNames(Idx) = strCtrlNames(Idx + 1)
intCtrlPos(Idx + 1) = tmpCtrlPos
strCtrlNames(Idx + 1) = tmpCtrlName
End If
Idx = Idx + 1
Wend
Wend
Idx = 0
While Idx < intCtrlCnt
If (Idx Mod 2 = 0) Then
MyCtrl = strCtrlNames(Idx)
If (MyCtrl <> "") Then
Me.Line (Me(MyCtrl).Left - 10, 0)-Step(Me(MyCtrl).Width + 10, MaxHt), lngBkColor, BF
End If
End If
Idx = Idx + 1
Wend
End Sub