hi,
I'm looking to use Access Pass-Through queries as a Record Source for reports. There's no Where clause in query.
Now in Docmd.OpenReport Where condition, using the query above, I want to search for records only for specific date.
I've created this query in order to avoid passing SQL from VBA code to keep it clean. Back-end is SQL Server.
Query runs fine if i run the report without Where condition, but displays nothing as soon as I put in this condition.
I'm pasting below a part from procedure calling the function, and function itself. What do I need to do please?
Thanks,
K
---------------Part of calling SP
'Call PTConnStr("qryEmp_w/o_WP")
If IsNull(Me.cbxDate) Then
DoCmd.OpenReport "rptEmp_w/o_WP", acViewReport
Else
DoCmd.OpenReport "rptEmp_w/o_WP", acViewReport, "DateComparison = '" & Me.cbxDate & "'"
End If
-------------Function
Function PTConnStr(queryName As String)
Dim qdef As QueryDef
Set qdef = CurrentDb.QueryDefs(queryName)
qdef.Connect = TempVars("ConnectionString").Value
qdef.ReturnsRecords = True
qdef.Close
'DoCmd.OpenQuery queryName
End Function
I'm looking to use Access Pass-Through queries as a Record Source for reports. There's no Where clause in query.
Now in Docmd.OpenReport Where condition, using the query above, I want to search for records only for specific date.
I've created this query in order to avoid passing SQL from VBA code to keep it clean. Back-end is SQL Server.
Query runs fine if i run the report without Where condition, but displays nothing as soon as I put in this condition.
I'm pasting below a part from procedure calling the function, and function itself. What do I need to do please?
Thanks,
K
---------------Part of calling SP
'Call PTConnStr("qryEmp_w/o_WP")
If IsNull(Me.cbxDate) Then
DoCmd.OpenReport "rptEmp_w/o_WP", acViewReport
Else
DoCmd.OpenReport "rptEmp_w/o_WP", acViewReport, "DateComparison = '" & Me.cbxDate & "'"
End If
-------------Function
Function PTConnStr(queryName As String)
Dim qdef As QueryDef
Set qdef = CurrentDb.QueryDefs(queryName)
qdef.Connect = TempVars("ConnectionString").Value
qdef.ReturnsRecords = True
qdef.Close
'DoCmd.OpenQuery queryName
End Function