我根据使用帮助设计了个查询窗口,前段时间在前辈的指点下把代码改成从后台查询了,但是现在有两个新问题
1.我的查询窗口有好几个查询条件,我现在只能在“版号”条件从后台查询,如果所有条件都能从后台查询,代码怎么改?
2.以前我的查询都是模糊查询,但是改为后台查询后成了精确查询了,这种情况代码怎么改?
下面是我的窗口和代码:
此主题相关图片如下:查询.jpg
Dim Filter As String
With e.Form.Controls("TextBH")
If .Value IsNot Nothing Then
Filter = "版号 like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("Textpm")
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("Textkh")
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("StartDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "接稿日期>= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "接稿日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
DataTables("产品信息查询表").LoadFilter ="版号 = '" & e.Form.Controls("textbh").Value & "'"
DataTables("产品信息查询表").Load
Tables("产品信息查询表").Filter = Filter
End If