以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  用按钮中加入代码动态改变打印范围,出错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130016)

--  作者:有点甜
--  发布时间:2019/1/11 9:47:00
--  

代码和模板都没问题。

 

加入代码弹出内容看一下 msgbox("<出差起日期 >= #" & qr & "# And 出差止时期 <= #" & zr & "#>" )

 

对应的,对表格筛选,看筛选结果是什么 Tables("蒋安出差").filter = "出差起日期 >= #" & qr & "# And 出差止时期 <= #" & zr & "#"


--  作者:有点甜
--  发布时间:2019/1/11 11:19:00
--  

你1楼的代码是没问题的。如果打印为空,说明你没有把表数据加载出来。

 

或者试试

 

If  Forms("出差打印").Opened = True Then
    Dim qr As Date = e.Form.Controls("qr").value
    Dim zr As Date = e.Form.Controls("zr").value
    If qr <> Nothing And zr  <>  Nothing Then
        If zr >= qr Then
            systemready = False
            Dim filter As String  =  "出差起日期 >= #" & qr & "# And 出差止日期 <= #" & zr & "#"  \' "出差起日期 >= #12-1-2018# And 出差起日期 <= #12-30-2018#"
            DataTables("蒋安出差").LoadFilter = filter
            DataTables("蒋安出差").Load
            Dim Book As New XLS.Book(ProjectPath & "Attachments\\公务用车记录单.xls") \'打开模板
            Dim fl As String = ProjectPath & "Reports\\123.xls"
            Dim Sheet As XLS.Sheet = Book.Sheets(0)
            Sheet(4,9).Value = "< " & filter & " >"
            Book.Build() \'生成报表
            Book.Save(fl)
            Dim Proc As New Process
            Proc.File = fl
            Proc.Start()
            systemready = True
        End If
    End If
End If