thmsjlmnt3953
Registered User.
- Local time
 - Today, 02:13
 
- Joined
 - May 20, 2014
 
- Messages
 - 120
 
Hi,
the below code works fine if i run a crosstab on a whole table however if i pass criteria to the crosstab e.g between [forms]![form]![txtstartdate] and [forms]![form]![enddate] it fails and returns null for every field? even though if set docmd.runquery "qryReductionByPhysician_Crosstab" this opens with the relevant data?
	
	
	
		
 the below code works fine if i run a crosstab on a whole table however if i pass criteria to the crosstab e.g between [forms]![form]![txtstartdate] and [forms]![form]![enddate] it fails and returns null for every field? even though if set docmd.runquery "qryReductionByPhysician_Crosstab" this opens with the relevant data?
		Code:
	
	
	Set db = CurrentDb
Set qdf = db.QueryDefs("qryReductionByPhysician_Crosstab")
indexx = 0
    For Each fld In qdf.Fields
        If fld.Type >= 1 And fld.Type <= 11 Then
            FieldList = FieldList & "[" & fld.Name & "] as Field" & indexx & ", "
            ReportLabel(indexx) = fld.Name
        End If
        MsgBox indexx
        indexx = indexx + 1
    Next fld
    For i = indexx To 31
            FieldList = FieldList & "null as Field" & i & ","
     Next i
     FieldList = Left(FieldList, Len(FieldList) - 1)
     
 strSQL = "Select " & FieldList & " From qryReductionByPhysician_Crosstab"
 
    db.QueryDefs.Delete "qryCrossTabReport"
    Set qdf = db.CreateQueryDef("qryCrossTabReport", strSQL)
 
 MsgBox strSQL
	
			
				Last edited: