That is a lot of spaghetti code, where one form is calling subs and clicking command buttons on several other Foms, even directing those Forms to do things to yet other Forms.
Also, I had to assume that "FilterFromCheckout" is a global variable that is set by many different processes, and that it is set/reset after the ProcessSearch sub is run.
Since ProcessSearch is only concerned with frmMain, I suggest moving it to frmMain and just passing the SearchString to it in the PatList Sub.
NOTE: I do NOT understand your code's program flow, so all this is only a suggestion!
frmX code 'Unknown Form name
Private Sub PatList_DblClick(Cancel As Integer)
On Error Goto Err_ErrorHandler
DoCmd.Echo False
'I don't understand your Forms well enough to make a recommendation here
If FilterFromCheckout = True Then
Forms("Checkout").ReturnToFrmMain 'This line looks really really dangerous, processing two Forms at once.
End If
frmMain.ProcessSearch Me.PatList.Value
Exit_ErrorHandler:
DoCmd.Echo True
Exit Sub
Err_ErrorHandler:
MsgBox Err.Description
Resume Exit_ErrorHandler
End Sub
frmMain Code
Sub ProcessSearch(SearchString As String)
Dim myrs As New ADODB.Recordset
myrs.Open "SELECT LargeData from settings", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
If myrs("LargeData") = True Then
Me.RecordSource = "SELECT * FROM tblPatient WHERE [MedicalID#] = '" & SearchString & "'"
DoCmd.Close acForm, "Search"
Else
If searchstring <> "" Then
DoCmd.Close acForm, "Search"
On Error Resume Next
DoCmd.FindRecord searchstring, acEntire, , acSearchAll, , acCurrent
'Can you move the call to the EPMSwitch code to here?
Forms("BatchPayment").LocatePatient searchstring
On Error Goto 0
End If
End If
myrs.Close
Set myrs = Nothing
If FilterFromCheckout = True Then
Me.EPMSwitch_Click 'Consider moving EPMSwitch Code to an "operative" Sub and calling that Sub here.
End If
End Sub
Finally: Every coder reaches a moment when they realize that if they had to do all over again, they would use what they learned in the first go around to do a much better job. The good ones start over.