I have converted an embedded macro to VBA. The macro worked with no problem. Now that it is converted to VBA when I click the button it displays a message box that just says Type mismatch.
The VBA code is as follows:
'------------------------------------------------------------
' Search_Click
'
'------------------------------------------------------------
Private Sub Search_Click()
On Error GoTo Search_Click_Err
TempVars.Add "strSearch", Replace(Forms!ViewStudyList!SearchBox, """", """""")
TempVars.Add "strFilter", "([PATIENT] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([MRN] Like "" * " & [TempVars]![strSearch] & " * "" )"
TempVars.Add "strFilter", TempVars!strFilter & " OR ([STUDY] Like "" * " & [TempVars]![strSearch] & " * "" )"
DoCmd.OpenForm "StudyList", acNormal, "", TempVars!strFilter, , acNormal
TempVars.Remove TempVars!strFilter
TempVars.Remove "strSearch"
DoCmd.Close acForm, "ViewStudyList"
Search_Click_Exit:
Exit Sub
Search_Click_Err:
MsgBox Error$
Resume Search_Click_Exit
End Sub
The command is supposed to execute a search of the PATIENT, MRN, and STUDYID fields that match whatever is entered in the search box.
Any suggestions are appreciated.