I've encountered the run time error '3075'. I'm a novice in VBA! >.< Can i know where did it went wrong? I can't solve it...
For e.g, if I enter a name "Sally" into a textbox (txtMainName), upon clicking on the search button the error pops-up.
The error:
Run-time error '3075':
Syntax error(missing operator) in query expression ' And [Main Applicant Name] Like 'Sally'".
Public Sub Search_Record()
Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria1 As String
Dim stLinkCriteria2 As String
stLinkCriteria = ""
stDocName = "frmDisplayInfo"
If (Me!txtMainName <> "") Then
stLinkCriteria1 = "[Main Applicant Name] Like ' " & Me![txtMainName] & "'"
stLinkCriteria = stLinkCriteria & " And " & stLinkCriteria1
End If
If (Me!txtIDNo <> "") Then
stLinkCriteria2 = "[ID No] Like ' " & Me![txtIDNo] & "'"
stLinkCriteria = stLinkCriteria & " And " & stLinkCriteria2
End If
'(*This part is highlighted*)
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
End Sub
stLinkCriteria
(the actual value it contains, not what you think it contains) when you get toDoCmd.OpenForm
? (Set a breakpoint at theOpenForm
line, run to that point, and look at whatstLinkCriteria
is when you get there.) – Calli