Have you run Debug>Compile?
Have you step debugged?
In my test the code errors in the SelectPatient function on the line:
qry.Parameters("lngStudyID") = lngStudyID
I modified the procedure to:
Code:
Private Function SelectPatient(ByVal lngStudyID As String)
DoCmd.OpenForm "FrmAuditTool", , , "VisitID = " & Me.txtMetricsID
DoCmd.Close acForm, "fdlgSearchPatient"
End Function
I also changed the RecordSource for FrmAuditTool to simply tblAudit. The qryFindMetricsID is not needed with these mods. If you want to leave this form open and repeat a search from fdlgSearchPatient, will need to expand the code to reset the form's filter criteria. That is what the original code is attempting to allow. I don't do this by altering query definition. I do this by setting the form's Filter and FilterOn properties. Otherwise, close the Audit form and start a new search.