Solved

Datagrid won't print

Posted on 2009-07-10
2
235 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Assisted Solution

by:game-master
game-master earned 500 total points
ID: 24837457


GOOD afternoon!

i have tried ur code and it works for me...
make sure u have set ur default printer...


game-master
0
 

Accepted Solution

by:
al4629740 earned 0 total points
ID: 24840690
Its funny.  It prints out, but nothing is on the page!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question