我遇到了运行时错误“3075”。我是VBA的新手!>.< 我能知道哪里出错了吗?我解决不了...
例如,如果我在文本框 (txtMainName) 中输入名称“Sally”,则在单击搜索按钮时会弹出错误。
错误:
运行时错误“3075”:
查询表达式中的语法错误(缺少运算符)“和 [主申请人姓名] 像 '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