Runtime error 3975 Invalid operator , according to a quick Google search on access vba runtime error 3075 (which you could do yourself).
The problem is that you only assign the value "" stCriteria . If the first if is stCriteria , stCriteria then set to stCriteria AND stCriteria1 , which is not valid.
The same thing happens if the second if is executed. (In fact, if both are actually running, stCriteria now contains AND stCriteria1 AND stCriteria2 , which is even worse.)
The solution is to modify your code to add AND if necessary:
stLinkCriteria = "" stDocName = "frmDisplayInfo" If (Me!txtMainName <> "") Then stLinkCriteria = "[Main Applicant Name] Like ' " & Me![txtMainName] & "'" End If If (Me!txtIDNo <> "") Then If stLinkCriteria <> "" then stLinkCriteria = stLinkCriteria & " AND " End If stLinkCriteria2 = "[ID No] Like ' " & Me![txtIDNo] & "'" stLinkCriteria = stLinkCriteria & " And " & stLinkCriteria2 End If
For further use, the way to solve these problems is to actually check the value of the variable (in this case stCriteria ) just before the line causing the error (here it is the DoCmd.OpenForm line) is executed, you do this by setting a breakpoint on line where the error occurs, run the application until a breakpoint is reached, and then check the value of the variable. This shows what exactly contains the variable that may reveal the problem.
source share