求窗口筛选按钮代码,要求筛选姓名列的重复姓名中的最后一行,如姓名为“张三”的最后一个的第三列是666的张三,但是第三列不作为筛选条件。
谢谢!
Dim dr As DataRow
Dim Filter As String '设置变量Filter,返回或设置过滤条件表达式
With e.Form.Controls("combobox1") '筛选单位,Controls引用窗口中名为cmbProduct组合框数据
If .Value IsNot Nothing Then '如果cmbProduct框不为空,则执行下面的语句
dr = DataTables("表A").Find("姓名 = '" & .Value & "'","[_Identify] Desc")
If dr IsNot Nothing Then
Filter = "[_Identify]= " & dr("_Identify") '在本表中的单位中查找
End If
If Filter > "" Then '如果筛选条件为空
Tables("表A").Filter = Filter '则不筛选
End If
End If
End With