比如我想打印满了一个A4纸就换页,或者数据库读到三十条记录就换页,怎么写?
Private Sub Command1_Click()
Dim a As Integer
a = Text1.Text
For i = 1 To a
Printer.FontSize = 14
Printer.CurrentX = 6
Printer.CurrentY = 100
Printer.Print Tab(38); "排班表"
Printer.FontSize = 12
Printer.Print " ┌────┬───┬───┬─────────┬────┬──────┬───────────┐"
Printer.Print " │ 车牌   │公里  │ 油费 │ 地址             │司机编号│  姓名      │  日期时间            │"
Adodc4.Refresh
Do While Not Adodc4.Recordset.EOF
Printer.Print " ├────┼───┼───┼─────────┼────┼──────┼───────────┤"
Printer.Print Tab(2); "│"; Adodc4.Recordset.Fields("车牌"); Tab(12); "│"; Adodc4.Recordset.Fields("公里"); Tab(20); "│"; Adodc4.Recordset.Fields("油费"); Tab(28); "│"; Adodc4.Recordset.Fields("地址"); Tab(48); "│"; Adodc4.Recordset.Fields("司机编号"); Tab(58); "│"; Adodc4.Recordset.Fields("姓名"); Tab(72); "│"; Adodc4.Recordset.Fields("日期"); Tab(96); "│"; ""
Adodc4.Recordset.MoveNext
Loop
Printer.Print " └────┴───┴───┴─────────┴────┴──────┴───────────┘"
Adodc4.Refresh
Printer.EndDoc
Printer.KillDoc
Next iEnd Sub

解决方案 »

  1.   

    加一个表头打印不就可以了,参考
    Do While Not Adodc4.Recordset.EOF
        If i > 29 Then
            Printer.Print " ┌────┬───┬───┬─────────┬────┬──────┬───────────┐"
            Printer.Print " │ 车牌  │公里  │ 油费 │ 地址            │司机编号│  姓名      │  日期时间            │"
            Printer.NewPage
            i = 0
        End If
        Printer.Print " ├────┼───┼───┼─────────┼────┼──────┼───────────┤"
        Printer.Print Tab(2); "│"; Adodc4.Recordset.Fields("车牌"); Tab(12); "│"; Adodc4.Recordset.Fields("公里"); Tab(20); "│"; Adodc4.Recordset.Fields("油费"); Tab(28); "│"; Adodc4.Recordset.Fields("地址"); Tab(48); "│"; Adodc4.Recordset.Fields("司机编号"); Tab(58); "│"; Adodc4.Recordset.Fields("姓名"); Tab(72); "│"; Adodc4.Recordset.Fields("日期"); Tab(96); "│"; ""
        Adodc4.Recordset.MoveNext
        i = i + 1
    Loop
      

  2.   

    楼主,为什么不用Excel呢?使用Excel做一个模板,每次要使用的时候复制这个模板,然后向复制的文件中填写内容即可,要打印,只需要简单的一条语句即可,既简单又实用