'选定你所要选定的区域,筛选代码你可以参照老六的窗口列子的筛选代码
Dim Filter As String
With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
Filter = "车辆基本情况_车牌号码 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "车辆基本情况_车牌颜色 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox2")
If .Value IsNot Nothing Then
Filter = "处理环节 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox3")
If .Value IsNot Nothing Then
Filter = "处罚情况_案件状态 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
Filter = "处理方式 = '" & .Value & "'"
End If
End With
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "违章基本情况_违章时间 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "违章基本情况_违章时间 <= #" & .Value & "#"
End If
End With
'筛选后全部选定区域
With Tables("车辆违章表")
.Select(0,0, .Rows.Count - 1, .Cols.Count - 1)
End With
'打印代码
Dim Book As New XLS.Book(ProjectPath & "Attachments\违章车辆统计报表.xls") '打开模板
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Book.Build() '生成细节区
Book.Save("D:\release\reports\违章车辆统计报表.xls") '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = "D:\release\reports\违章车辆统计报表.xls"
Proc.Verb = "Print" '加上这个可以直接打印,去掉只能预览
Proc.Start()
此主题相关图片如下:捕获.png


此主题相关图片如下:捕获1.png