Private Sub Command1_Click()
imprimir
End Sub
Private Sub Form_Load()
Call data_connect
rs.Open "Select * from IRCTB1", db
Set DataGrid1.DataSource = rs
DataGrid1.Height = 5565
DataGrid1.RowHeight = 400
show_rec
End Sub
Public Sub show_rec()
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
End Sub
Public Function imprimir(ByVal datos As DataGrid, ByVal datas As Adodc, ByVal tit As String) As Long
Dim MyRows, MyCols As Integer 'for-loop counters
Dim MyText As String 'text To be printed
Dim Titles As String 'column titles
Dim Header As String 'page headers
Dim MyLines As Integer 'number of lines For portrait
Dim LLCount As Integer 'temporary line counter
Dim MyArray(20) As Integer
Dim Rowado, Rowdatag As Integer
Dim Mtittle As String
Screen.MousePointer = vbHourglass
Titles = ""
LLCount = 0
Mtitle = Space(40) & tit
Header = " - Page: " 'setup page header
'get column headers
For MyCols = 1 To datos.Columns.Count
MyArray(MyCols) = Len(datos.Columns(MyCols - 1).Caption) + 10
Titles = Titles & Space(10) & datos.Columns(MyCols - 1).Caption
Next MyCols
'setup printer
Printer.Font.Size = 8 '8pts font size
Printer.Font.Bold = True 'titles To be bold
Printer.Font.Name = "Courier New" 'courier new font
Printer.Orientation = vbPRORPortrait
MyLines = 82
Printer.Print Mtitle
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Font.Bold = False
'get column/row values
datas.Refresh
datos.Refresh
For Rowado = 1 To Int((datas.Recordset.RecordCount - 1) / 13) + 1
For Rowdatag = 0 To datos.VisibleRows - 1
datos.RowBookmark (Rowdatag)
MyText = Space(10)
For MyCols = 1 To datos.Columns.Count
[B]MyText = MyText & datos.Columns(MyCols - 1).CellText(datos.Bookmark) &[/B] [I]>>> [U]the bold text is shown in RED COLOR[/U][/I] Space (MyArray(MyCols) - Len(datos.Columns(MyCols - 1).CellText(datos.Bookmark)))
Next MyCols
LLCount = LLCount + 1
If LLCount <= MyLines Then
Printer.Print MyText
Else
Printer.NewPage
Printer.Print Mtitle
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Print MyText
LLCount = 0
End If
datas.Recordset.MoveNext
Next Rowdatag
datos.Scroll 0, datos.VisibleRows
Next Rowado
Printer.Print " "
Printer.EndDoc
Screen.MousePointer = vbNormal
End Function