DataReport Grouping
I am passing the sql statement to the datareport and I include the Group By in that. I have only a Detail section on my datareport. I have tried adding a group section to the report, only to receive an error. Here is my code. Thanks for any suggestions.
With deNascar
'set SQL if needed
sCmdSQL = "SELECT DriverName,DriverCarNo,"
sFrom = " from Drivers where Season=" & Left(cboSeason.Text, 4)
If icboLapNum = 1 then
sCmdSQL = sCmdSQL & "Lap1Group"
sGroupBy = " Group By Lap1Group,DriverName,DriverCarNo"
sOrderBy = " Order by Lap1Group,DriverName"
else
sCmdSQL = sCmdSQL & "Lap2Group"
sGroupBy = " Group By Lap2Group,DriverName,DriverCarNo"
sOrderBy = " Order by Lap2Group,DriverName"
End If
.Commands(1).CommandText = sCmdSQL & sFrom & sGroupBy & sOrderBy
'set report title and other controls if needed
With drDriverList.Sections("secRepHeader").Controls
.Item("lblRptTitle").Caption = Left(cboSeason.Text, 4) & " " _
& sReportTitle & " for Lap " & icboLapNum
.Item("lblLapGrp").Caption = "Lap " & icboLapNum & " Group"
End With
With drDriverList.Sections("secDetail").Controls
.Item("txtLapGrp").DataField = "Lap" & icboLapNum & "Group"
End With
.Commands(1).Execute
'Show report
drDriverList.Refresh
drDriverList.Show vbModal
If .rsCommand1.State = 1 then
.rsCommand1.Close
End If
End With
Greg

