Click to See Complete Forum and Search --> : Print grid on the printer - Help !!!!!!
Matt-D
Jan 14th, 2000, 11:29 AM
There is a grid (standard project, normal VB-grid) filled by an Access 1.10 database (SQl) and I want to print it out on the printer, but with the method I know the printer only gives out an empty paper :( :
_ Printer.Print Grid1
_ Printer.EndDoc
What have I to do here (!!VB3!!) ???????
I'm asking and asking again, perhaps someone knows :) :) :D ,) .........
If you have any questions you cand semd me an eMail.
Aaron Young
Jan 14th, 2000, 11:36 AM
You definitely need to upgrade to at least VB5..
As the other methods we've suggested don't seem to have worked for you, lets try accessing the Data directly from the Access DB and forget the Grid, ie.
Private Sub Command1_Click()
Dim oDB As Database
Dim oRS As Recordset
Dim iField As Integer
Set oDB = OpenDatabase("C:\Files\Db1.mdb")
Set oRS = oDB.OpenRecordset("SELECT * FROM MyTable", dbOpenForwardOnly)
While Not oRS.EOF
For iField = 0 To oRS.Fields.Count - 1
Printer.Print oRS(iField) & " ";
Next
Printer.Print
oRS.MoveNext
Wend
Printer.EndDoc
oRS.Close
oDB.Close
MsgBox "All Done", vbInformation, "Print Data"
End Sub
This may need some Formatting, but at least it will get it out onto the Printer.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
MartinLiss
Jan 14th, 2000, 11:49 AM
Besides upgrading to VB5 or 6, he will need to use MSFlexGrid (or some third party grid) rather than the MS Grid control he is now using. When I first saw his question I thought the answer would be a simple MyForm.PrintForm which (after hiding the other non-Grid objects) works just fine in one of my projects that uses a flex grid. When I tried it with the old MS Grid however, the contents of the grid did not show up.
------------------
Marty
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.