Dim Filter As String
With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "通用名称 like '%" & .Value & "%'"
End If
End With
With e.Form.Controls("TextBox7")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim nf As String=e.Form.Controls("TextBox7").text
Dim nfd1 As Date
Dim nfd2 As Date
If nf.Length=4 Then
nfd1 = new Date(nf.SubString(0,4),1,1)
nfd2=nfd1.AddYears(1)
Filter ="来货日期 >=#"& nfd1 &"# And 来货日期 <#"& nfd2 &"#"
Else
MessageBox.Show("年份位数不对,只能4位数!", "提示")
End If
End If
End With
Tables("窗口_Table1").Filter = Filter
上面的代码中TextBox2 和TextBox7 同时输入查询条件时,筛查不出想要的记录。烦老师帮看看代码哪里有问题?