Hello,
I have successfully created a dynamic crosstab report in access which uses a crosstab query to populate my report.
Problem:
I need to add additional queries to this report.
Question:
Is it possible to create a dynamic crosstab from multiple recordsets?
Below is my current code for the Detail/Format section:
Thanks in advance
I have successfully created a dynamic crosstab report in access which uses a crosstab query to populate my report.
Problem:
I need to add additional queries to this report.
Question:
Is it possible to create a dynamic crosstab from multiple recordsets?
Below is my current code for the Detail/Format section:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' Put values in text boxes and hide unused text boxes.
Dim intX As Integer
' Verify that you are not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, put values from recordset into text boxes
' in "Detail" section.
If Me.FormatCount = 1 Then
For intX = 1 To intColumnCount
' Convert Null values to 0.
Me("Comp" + Format(intX)) = xtabCnulls(rstReport(intX - 1))
Me("Can" + Format(intX)) = xtabCnulls(rstReport(intX - 1))
Next intX
' Hide unused text boxes in the "Detail" section.
For intX = intColumnCount + 2 To conTotalColumns
Me("Comp" + Format(intX)).Visible = False
Me("Can" + Format(intX)).Visible = False
Next intX
' Move to next record in recordset.
rstReport.MoveNext
End If
End If
End Sub
Also, the code below sets up my recordset:
CODE
Private Sub Report_Open(Cancel As Integer)
' Create underlying recordset for report using criteria entered in
Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form
' Set database variable to current database.
Set dbsReport = CurrentDb
Set frm = Forms!Monthly_Client_Individual_Frm
' Open QueryDef object.
Set qdf = dbsReport.QueryDefs("Totals_Crosstab")
' Set parameters for query based on values entered
qdf.Parameters(0) = Forms![Monthly_Client_Individual_Frm]![CustName_Cmb]
' Open Recordset object.
Set rstReport = qdf.OpenRecordset()
' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstReport.Fields.Count
End Sub