With Tables("台账查询_table1")
If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
.filter =""
Else
If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" Then
.filter = "品号 = '" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' "
Else
If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker2").text ="" And e.Form.Controls("DropBox1").text ="" Then
.filter ="日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# "
Else
If e.Form.Controls("ComboBox1").text = "" And e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DropBox1").text ="" Then
.filter = "日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
Else
If e.Form.Controls("DateTimePicker1").text ="" And e.Form.Controls("DateTimePicker2").text ="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "'and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DropBox1").text="" And e.Form.Controls("DateTimePicker1").text="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
Else
If e.Form.Controls("DateTimePicker2").text="" And e.Form.Controls("DropBox1").text="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" & e.Form.Controls("DateTimePicker1").text & "# "
Else
If e.Form.Controls("DropBox1").text ="" And e.Form.Controls("ComboBox1").text="" Then
.filter ="日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# "
Else
If e.Form.Controls("DateTimePicker1").text="" And e.Form.Controls("ComboBox1").text="" Then
.filter = "日期 <= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DateTimePicker1").text="" And e.Form.Controls("ComboBox1").text="" Then
.filter = "日期 >= #" & e.Form.Controls("DateTimePicker1").text & "# and 品号 ='" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DropBox1").text ="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# "
Else
If e.Form.Controls("ComboBox1").text = "" Then
.filter = "日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DateTimePicker1").text="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
Else
If e.Form.Controls("DateTimePicker2").text="" Then
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
Else
.filter = "仓库 = '" & e.Form.Controls("ComboBox1").text & "' and 日期 >= #" &e.Form.Controls("DateTimePicker1").text & "# and 日期<= #" & e.Form.Controls("DateTimePicker2").text & "# and 品号 = '" & e.Form.Controls("DropBox1").text & "' "
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End With
那位大神能帮忙简化下代码