Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

Datagrid won't print

Below I pasted my code that I use to print my datagrid.  However, nothing is printing out.  Paper comes out blank.  Can anyone figure out why that is happening?
Private Sub PrintGrid(ctlGrid As Control)
Dim i As Integer
Dim j As Integer
Dim PTab As Integer
 
Printer.Orientation = vbPRORLandscape
 
 
   With ctlGrid
'       PTab = 35 'Set the first tab value
       
'       For j = 0 To .Columns.Count - 1
 '          .col = j 'Set the current column
       
           'Send the field to the print line and add the tab.
           'Notice the semicolon at the end of the line.
'           Printer.Print Trim$(.Columns(j).Caption); Tab(PTab);
       
 '          PTab = PTab + 30 'Increment the tab value
  '     Next
   '    Printer.Print
       
       For i = 0 To .ApproxCount - 1
       
            PTab = 20 'Set the first tab value
           
           'This checks to see if a page break is needed
           If Printer.CurrentY + Printer.TextHeight(.text) > Printer.ScaleHeight - 600 Then
               Printer.NewPage
           End If
           
           For j = 0 To .Columns.Count - 1
               .Col = j 'Set the current column
           
               'Send the field to the print line and add the tab.
               'Notice the semicolon at the end of the line.
               Printer.Print Trim$(.text); Tab(PTab);
           
               PTab = PTab + 20 'Increment the tab value
               
               
           Next
           
            
           'After each column has printed to the print line
           'a Printer.Print statement without a semicolon will
           'will send the line to the printer and start a new
           'one.
           
           
           Printer.Print
           
           On Error Resume Next
           .Row = .Row + 1 'Set the active row
           On Error GoTo 0
           
       Next i
   End With
   Printer.EndDoc
End Sub

Open in new window

SOLUTION
Avatar of game-master
game-master
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial