Hi all, I would really appreciate if you could help me with this one. I created a dynamic crosstab report with 4 unbound fields in the details section and 4 unbound fields in the header section, which all work perfectly well. However when I want to get the sum in the footer section I get stuck, and I can´t figure out what I´m doing wrong.
The crosstab query contains 17 columns. The last 4 columns contain the values I need to take the sum of.
I have put some code in the open event procedure of the report.
Private Sub Report_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from Que_ProjectUren_Sel_Dept_Test")
'details section
Me.wk1.ControlSource = rs.Fields(13).Name
Me.WK2.ControlSource = rs.Fields(14).Name
Me.WK3.ControlSource = rs.Fields(15).Name
Me.WK4.ControlSource = rs.Fields(16).Name
´Header section
Me.lblWK1.Caption = rs.Fields(13).Name
Me.lblWK2.Caption = rs.Fields(14).Name
Me.lblWK3.Caption = rs.Fields(15).Name
Me.lblWK4.Caption = rs.Fields(16).Name
´Footer section
‘ I know that the code must be something like this, because when I put the column names from the ‘crosstab query all works well
Me.SumWk1.ControlSource = "=sum([me.wk14])"
Me.SumWk1.ControlSource = "=sum([me.WK15])"
Me.SumWk1.ControlSource = "=sum([me.WK16])"
Me.SumWk1.ControlSource = "=sum([me.WK17])"
rs.Close
End Sub
The crosstab query contains 17 columns. The last 4 columns contain the values I need to take the sum of.
I have put some code in the open event procedure of the report.
Private Sub Report_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from Que_ProjectUren_Sel_Dept_Test")
'details section
Me.wk1.ControlSource = rs.Fields(13).Name
Me.WK2.ControlSource = rs.Fields(14).Name
Me.WK3.ControlSource = rs.Fields(15).Name
Me.WK4.ControlSource = rs.Fields(16).Name
´Header section
Me.lblWK1.Caption = rs.Fields(13).Name
Me.lblWK2.Caption = rs.Fields(14).Name
Me.lblWK3.Caption = rs.Fields(15).Name
Me.lblWK4.Caption = rs.Fields(16).Name
´Footer section
‘ I know that the code must be something like this, because when I put the column names from the ‘crosstab query all works well
Me.SumWk1.ControlSource = "=sum([me.wk14])"
Me.SumWk1.ControlSource = "=sum([me.WK15])"
Me.SumWk1.ControlSource = "=sum([me.WK16])"
Me.SumWk1.ControlSource = "=sum([me.WK17])"
rs.Close
End Sub