I'm writing a crosstab report that will have dynamic headers to match the headers in my crosstab query. An integral part of this, of course, is accessing the Fields property of the query def. For now, I'm just starting with a field count. For some reason, I keep getting a field count of 0. Here's my code from the report (which works with other databases/crosstab queries and in my current db if I switch the query from crosstab to select):
CODE
Private Sub Report_Open(Cancel As Integer)
Dim db As Database, Qrydef As QueryDef, fldcount As Integer
Set db = CurrentDb
Set Qrydef = db.QueryDefs("a_TEMP")
fldcount = Qrydef.Fields.Count
MsgBox fldcount, vbOKOnly, "Field Count"
End Sub
Dim db As Database, Qrydef As QueryDef, fldcount As Integer
Set db = CurrentDb
Set Qrydef = db.QueryDefs("a_TEMP")
fldcount = Qrydef.Fields.Count
MsgBox fldcount, vbOKOnly, "Field Count"
End Sub
Here is the code for my crosstab query which, of course, looks beautiful in datasheet view (it has 10 fields)...
CODE
PARAMETERS [Forms]![frmDrRptSelectionMenu]![txtDrName] IEEEDouble;
TRANSFORM Sum(qryDr_InptAdmits.NoInptAdmits) AS SumOfNoInptAdmits
SELECT qryDr_InptAdmits.DrNo
FROM qryDr_InptAdmits
GROUP BY qryDr_InptAdmits.DrNo
PIVOT qryDr_InptAdmits.MonthOfService;
TRANSFORM Sum(qryDr_InptAdmits.NoInptAdmits) AS SumOfNoInptAdmits
SELECT qryDr_InptAdmits.DrNo
FROM qryDr_InptAdmits
GROUP BY qryDr_InptAdmits.DrNo
PIVOT qryDr_InptAdmits.MonthOfService;
Any ideas why I'm getting a field count of 0? Thanks in advance!
Kate