Foxtable(狐表)用户栏目专家坐堂 → Syntax error: Missing operand before 'And' operator.


  共有3158人关注过本帖树形打印复制链接

主题:Syntax error: Missing operand before 'And' operator.

帅哥哟,离线,有人找我吗?
yetle
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
Syntax error: Missing operand before 'And' operator.  发帖心情 Post By:2020/3/11 8:53:00 [只看该作者]

弹出提示:Syntax error: Missing operand before 'And' operator.
代码:
Dim filter As String = "1=1"

Dim ddh As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim gys As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim lm As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim ys As WinForm.TextBox = e.Form.Controls("TextBox4")
Dim kh As WinForm.TextBox = e.Form.Controls("TextBox5")
Dim wgh As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim v As Integer = wgh.text
Dim qs As WinForm.RadioButton = e.Form.Controls("RadioButton1")
Dim qb As WinForm.RadioButton = e.Form.Controls("RadioButton2")



With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
    If ddh.text>"" Then
      Filter = Filter & " And "
    Else
         filter=filter & "[采购单号] like '" & ddh.text & "'"       
     End If

End If
End  With

With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
    If gys.text>"" Then
      Filter = Filter & " And "

    End If
       filter=filter & "[供应商属性_供应商名称] like '%" & gys.text & "%'" 
End If
End  With

With e.Form.Controls("TextBox3")
If .Value IsNot Nothing Then
    If lm.text>"" Then
      Filter = Filter & " And "

    End If
       filter=filter & "[物料基本信息_物料名称] like '%" & lm.text & "%'" 

End If
End  With


With e.Form.Controls("TextBox4")
If .Value IsNot Nothing Then
    If ys.text>"" Then
      Filter = Filter & " And "

    End If
       filter=filter & "[物料配色] like '" & ys.text & "'"
 
End If
End  With

With e.Form.Controls("TextBox5")
If .Value IsNot Nothing Then
    If kh.text>"" Then
      Filter = Filter & " And "

    End If
       filter=filter & "[款号] like '%" & kh.text & "%'" 
End If
End  With

With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
    If wgh.text>"" Then
      Filter = Filter & " And "

    End If
       filter=filter & "[物供号] = "& v &" " 

End If
End  With


If Filter > "" Then
      If  qs.Checked = True Then   
    Tables("选择到货物检_table3").Filter=filter & " and  [到货数] > [入库数] "

      Else If qs.Checked = False Then
    Tables("选择到货物检_table3").Filter=filter
      End If


End If

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110558 积分:562680 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/11 9:01:00 [只看该作者]

其它地方按照下面说明自行改正

With ddh
If .Value IsNot Nothing Then
    If Filter > "" Then  '这个地方不需要改动,请保持原样,意思是如果之前已经添加了条件,就增加一个and连接符
      Filter = Filter & " And "
    Else
         filter=filter & "[采购单号] like '" & ddh.text & "'"       
     End If

End If
End  With

 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2020/3/11 9:46:00 [只看该作者]

都改过了,还是一样的提示
[此贴子已经被作者于2020/3/11 9:58:27编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110558 积分:562680 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/11 9:50:00 [只看该作者]

改之后的代码重新发上来

msgbox(Filter) 看看最后弹出的条件

 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2020/3/11 10:52:00 [只看该作者]

只在ComboBox1选择了值,查找不会弹出提示,加了其他输入框的条件组合查询会弹出提示,且msgbox(Filter) 弹出的值是一样,都是"1=1"and物供号=选择的值
Dim filter As String = "1=1"

Dim ddh As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim gys As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim lm As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim ys As WinForm.TextBox = e.Form.Controls("TextBox4")
Dim kh As WinForm.TextBox = e.Form.Controls("TextBox5")
Dim wgh As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim v As Integer = wgh.text
Dim qs As WinForm.RadioButton = e.Form.Controls("RadioButton1")
Dim qb As WinForm.RadioButton = e.Form.Controls("RadioButton2")



With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
    'If ddh.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "
    Else
         filter=filter & "[采购单号] like '" & ddh.text & "'"       
     End If

End If
End  With

With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
    'If gys.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "

    End If
       filter=filter & "[供应商属性_供应商名称] like '%" & gys.text & "%'" 
End If
End  With

With e.Form.Controls("TextBox3")
If .Value IsNot Nothing Then
    'If lm.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "

    End If
       filter=filter & "[物料基本信息_物料名称] like '%" & lm.text & "%'" 

End If
End  With


With e.Form.Controls("TextBox4")
If .Value IsNot Nothing Then
    'If ys.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "

    End If
       filter=filter & "[物料配色] like '" & ys.text & "'"
 
End If
End  With

With e.Form.Controls("TextBox5")
If .Value IsNot Nothing Then
    'If kh.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "

    End If
       filter=filter & "[款号] like '%" & kh.text & "%'" 
End If
End  With

With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
    'If wgh.text>"" Then
If Filter > "" Then 
      Filter = Filter & " And "

    End If
       filter=filter & "[物供号] = "& v &" " 

End If
End  With


If Filter > "" Then
      If  qs.Checked = True Then   
    Tables("选择到货物检_table3").Filter=filter & " and  [到货数] > [入库数] "

      Else If qs.Checked = False Then
    Tables("选择到货物检_table3").Filter=filter
      End If


End If
msgbox(Filter) 
[此贴子已经被作者于2020/3/11 10:58:17编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110558 积分:562680 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/11 11:06:00 [只看该作者]

……
    End If
       filter=filter & "[物供号] = "& v &" " 
End If
End  With
msgbox(Filter) 输入所有的条件,弹出的内容截图发上来看看

If Filter > "" Then
      If  qs.Checked = True Then  
……

 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2020/3/11 11:48:00 [只看该作者]

还是有这个错误
图片点击可在新窗口打开查看此主题相关图片如下:76796265-7946-4f92-b398-e76d5a5457f8.png
图片点击可在新窗口打开查看

 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110558 积分:562680 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/11 12:05:00 [只看该作者]

错误的用法
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        Else
            filter=filter & "[采购单号] like '" & ddh.text & "'"
        End If
        
    End If
End  With

正确的用法,其它条件自己检查
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        filter=filter & "[供应商属性_供应商名称] like '%" & .Value & "%'"
    End If
End  With

 回到顶部