SimonPGreen
IS-IT--Management
Hi all,
Blatantly ripped off Getz, Litwin & Gilberts code to create a dynamic report base on a crosstab as follows:
Problem I have is that I cannot get the totals in the footer to work with the line
The field name is a date in the format 04/03/2007 etc however Jet complains that there is an extra ) in query expression '[sum([04/03/2007])]' for example.
Any ideas?
Simon
Blatantly ripped off Getz, Litwin & Gilberts code to create a dynamic report base on a crosstab as follows:
Code:
Private Sub Report_Open(Cancel As Integer)
Dim intColCount As Integer
Dim intControlCount As Integer
Dim i As Integer
Dim strName As String
On Error Resume Next
Dim rst As adodb.Recordset
Set rst = New adodb.Recordset
rst.Open _
Source:=Me.RecordSource, _
ActiveConnection:=CurrentProject.Connection, _
options:=adCmdTable
intColCount = rst.Fields.Count
intControlCount = Me.Detail.Controls.Count
If intControlCount < intColCount Then
intColCount = intControlCount
End If
For i = 1 To intColCount
strName = rst.Fields(i - 1).Name
Me.Controls("lblHeader" & i).Caption = strName
Me.Controls("txtData" & i).ControlSource = strName
'Me.Controls("txtSum" & i).ControlSource = "sum([" & strName & "])"
Next i
For i = intColCount + 1 To intControlCount
Me.Controls("txtData" & i).Visible = False
Me.Controls("lblHeader" & i).Visible = False
Me.Controls("txtSum" & i).Visible = False
Next i
rst.Close
End Sub
Problem I have is that I cannot get the totals in the footer to work with the line
Code:
Me.Controls("txtSum" & i).ControlSource = "sum([" & strName & "])"
The field name is a date in the format 04/03/2007 etc however Jet complains that there is an extra ) in query expression '[sum([04/03/2007])]' for example.
Any ideas?
Simon