【问题标题】:Searching a name in a subform table via vba using combo box使用组合框通过 vba 在子表单表中搜索名称
【发布时间】:2016-06-19 05:02:28
【问题描述】:

我正在尝试使用组合框从父表单中对子表单上的名称进行搜索过滤器,我已经设法搜索日期,我现在正在尝试根据客户名称进行搜索...我有,但它不起作用...

    Me.subform.Form.Filter = "[Client]=& me.cboClientName&"

我设法像这样按日期搜索指令....

    Me.subform.Form.Filter = "[AppointDate]=#" & Format(Me.cbSelectDate, "yyyy-mm-dd") & "#"

【问题讨论】:

    标签: vba ms-access


    【解决方案1】:

    您必须将字符串与搜索列和组合框的值连接起来,并且您必须应用过滤器。

    Dim strFilter as string
    
    'first print what you did
    strFilter =  "[Client]=& me.cboClientName&"
    Debug.Print "Your faulty filter: " & strFilter ' shown in immediate window
    
    'now with concat
    strFilter = "[Client]= '" & Me.cboClientName & "'" ' suround by quotes because I assume it's a string
    Debug.Print "filter: " & strFilter
    
    Me.subform.Form.Filter = strFilter
    Me.subform.Form.FilterOn = true ' activate the Filter
    

    【讨论】:

      猜你喜欢
      • 2023-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多