Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please some one help >> printing DBGrid

Status
Not open for further replies.

ALSayegh

Programmer
Mar 27, 2001
25
KW
Hi
How can I print a content of a DBGrid?






 
Hi Alsayegh -

Have you tried PrintForm ?
If that does not show the detail.... try the following code
... I have used it to print contents of a MSFlexGrid

- Add a Picture control to your grid form
- set visible to FALSE

Please reply back to this forum to tell me if this
worked for you.

John



Private Sub btnPrintGrid_Click()
'When the form contains a M$FlexGrid, the usual way of printing a form, the PrintForm method,
'will result in no grid data showing on the print-out.
'Sooo... this sub copies the grid image to a Picture control,
'then sends the Picture control to the printer.
'It works surprisingly well and is much easier than exporting
'data to an Excel worksheet for the purpose of printing.
'Note: Make the Picture controls VISIBLE property = False
'This method works in VB 6.
'(I dont know if all the data will print when the grid contains
'more rows than can fit on 1 screen)

Dim sScale As Double
Dim sHeading As String
sHeading = "Frigidaire: Virtual Loads"

Printer.Orientation = vbPRORLandscape
Picture1.Picture = MSFlexGrid1.Picture
sScale = Printer.ScaleHeight * (MSFlexGrid1.Rows / 50)
Printer.CurrentX = 100
Printer.Font = "Arial"
Printer.FontSize = "14"
Printer.FontBold = False
Printer.Print sHeading
' print the date/time
' move down a line
Printer.CurrentX = 0
Printer.CurrentY = Printer.TextHeight(sHeading) * 1
Printer.Print "Date: " & Now
Printer.PaintPicture Picture1.Picture, 0, 500, Printer.ScaleWidth, sScale
Printer.EndDoc

End Sub
 
I tried your way .. but .. dose not work

Thanks for your help
 
I tried it on mine and it works. I just wish you can have more control on the product. Mine prints two thirds of the way and then cuts off the printing.
 
ALSayegh - we need alot more information than just "it does not work" to be able to help you.

TondoBoy - You said it only printed two thirds of the grid ?

Maybe you could adjust the settings in the Printer.PaintPicture line OR change to a smaller Font
setting to see if you then get more detail lines printed...
just a thought.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top