Group By
Hi,
Can somebody please help. I have a program that after it runs it creates a report based on several tables. Everything works great except for one thing. I have the following code that sets up the report. The problem is that although it groups the id field it does not put like id in one line with a total for the qty field. I would like to report to put identical id in one line.
Any help?
Todd
For example:
id qty
2412 20
2413 10
2414 20
Not Like This
Id qty
2412 5
2412 5
2412 5
2412 5
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim cn As New ADODB.Connection
Dim strSQL As String
cn.Open "Provider=MSDATASHAPE; data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Invpath & "\data\Inventory.mdb;Persist Security Info=False"
strSQL = "Select * from jobpart where jobid='" & jobinprocessRS!JOBID & "'"
With cmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = " SHAPE {" & strSQL & "} AS cmdGroup1 Compute cmdGroup1 BY 'id'"
.Execute
End With
With rs
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd
End With
With DataReport3
Set .DataSource = rs
.DataMember = ""
'this for group header
With .Sections("section2").Controls
.Item("Text1").DataField = "id"
End With
'this for group details
With .Sections("Section1").Controls
.Item("Text2").DataMember = "cmdGroup1"
.Item("Text2").DataField = "id"
.Item("Text3").DataMember = "cmdGroup1"
.Item("Text3").DataField = "qty"
End With
.Refresh
.Show
End With
|