Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Crosstab Report with Multiple Queries

Status
Not open for further replies.

TaylorTot

Technical User
Dec 23, 2003
96
US
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:
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

Thanks in advance :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top