求助!!!access VBA代码提示操作符丢失

sinat_31005149 2015-09-02 10:12:00
代码如下:

Private Sub CMD查询_Click()

Dim strWhere As String

strWhere = ""

If Not IsNull(Me.编号) Then
strWhere = strWhere & "([编号] like '*" & Me.编号 & "*') AND "
End If

If Not IsNull(Me.所属乡镇) Then
strWhere = strWhere & "([所属乡镇] like '*" & Me.所属乡镇 & "*') AND "
End If

If Not IsNull(Me.经度) Then
strWhere = strWhere & "([经度] like '*" & Me.经度 & "*') AND "
End If

If Not IsNull(Me.设备种类) Then
strWhere = strWhere & "([设备种类] like '*" & Me.设备种类 & "*') AND "
End If

If Not IsNull(Me.建设时间) Then
strWhere = strWhere & "([建设时间] like '" & Me.建设时间 & "') AND "
End If

If Not IsNull(Me.纬度) Then
strWhere = strWhere & "([纬度] like '" & Me.纬度 & "') AND "
End If

If Not IsNull(Me.位置1) Then
strWhere = strWhere & "([位置1] like '" & Me.位置1 & "') AND "
End If

If Not IsNull(Me.位置2) Then
strWhere = strWhere & "([位置2] like '" & Me.位置2 & "') AND "
End If

If Not IsNull(Me.道路名称修改备注) Then
strWhere = strWhere & "([道路名称修改备注] like '" & Me.道路名称修改备注 & "') AND "
End If

If Not IsNull(Me.点位名称) Then
strWhere = strWhere & "([点位名称] like '" & Me.点位名称 & "') AND "
End If

If Not IsNull(Me.所属中队) Then
strWhere = strWhere & "([所属中队] like '" & Me.所属中队 & "') AND "
End If

If Not IsNull(Me.建设单位) Then
strWhere = strWhere & "([建设单位] like '" & Me.建设单位 & "') AND "
End If

Debug.Print strWhere

Me.[总表子窗体].Form.Filter = strWhere
Me.[总表子窗体].Form.FilterOn = True

Exit_CMD查询_Click:
Exit Sub

Err_CMD查询_Click:
MsgBox Err.Description
Resume Exit_CMD查询_Click

End Sub
...全文
209 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tiger_Zhao 2015-09-07
  • 打赏
  • 举报
回复
Debug.Print strWhere 什么内容?
具体的错误信息?
sinat_31005149 2015-09-05
  • 打赏
  • 举报
回复
引用 1楼Tiger_Zhao 的回复:
你的条件最后多出一个 AND 关键字,要去掉
    If Len(strWhere) <> 0 Then
strWhere = Left(strWhere, Len(strWhere) - 4)
End If
还是报一样的错
Tiger_Zhao 2015-09-04
  • 打赏
  • 举报
回复
你的条件最后多出一个 AND 关键字,要去掉
    If Len(strWhere) <> 0 Then
strWhere = Left(strWhere, Len(strWhere) - 4)
End If

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧