I do not know if this is possible even but I am trying to use Querydef parameters to provide the recordsource for a report. I thought this would be far more efficient than using a filter on the report when the base table has thousands of records. I have tried the following code but the report still asks for a value for the parameter.
Public Function AddNewNotesTrace(ByVal pHospNo As String, _
ByRef pdbsCurrent As DAO.Database) As Boolean
'inserts a new notes trace record for the given patient
'returns a true value if successful
Dim qdfAddNew As DAO.QueryDef
Dim prmPatient As DAO.Parameter
On Error GoTo AddNewPatient_Err
AddNewNotesTrace = False
Set qdfAddNew = pdbsCurrent.QueryDefs("selHospNo")
Set prmPatient = qdfAddNew.Parameters("HospNo")
prmPatient.Value = pHospNo
DoCmd.OpenReport "rptHospNo", acViewPreview
Set prmPatient = Nothing
Set qdfAddNew = Nothing
AddNewNotesTrace = True
Exit Function
AddNewPatient_Err:
'error handler
End Function
Can it be done? Any help/advice would be appreciated.
Thanks
Jonathan
Public Function AddNewNotesTrace(ByVal pHospNo As String, _
ByRef pdbsCurrent As DAO.Database) As Boolean
'inserts a new notes trace record for the given patient
'returns a true value if successful
Dim qdfAddNew As DAO.QueryDef
Dim prmPatient As DAO.Parameter
On Error GoTo AddNewPatient_Err
AddNewNotesTrace = False
Set qdfAddNew = pdbsCurrent.QueryDefs("selHospNo")
Set prmPatient = qdfAddNew.Parameters("HospNo")
prmPatient.Value = pHospNo
DoCmd.OpenReport "rptHospNo", acViewPreview
Set prmPatient = Nothing
Set qdfAddNew = Nothing
AddNewNotesTrace = True
Exit Function
AddNewPatient_Err:
'error handler
End Function
Can it be done? Any help/advice would be appreciated.
Thanks
Jonathan