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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Print Data Report in Network Printer

Status
Not open for further replies.

Rasheed Shaik

Programmer
Mar 20, 2011
23
SA
How to print a data report in Network Printer in a VB 6 application?
 
Try with this one ...

Dim prt As Printer
For Each prt In Printers
If prt.DeviceName = "MyPrinterName" Then
Set Printer = prt
Exit For
End If
Next



Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Private rs As New ADODB.recordset
Dim obj As PageSet.PrinterControl
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Set obj = New PrinterControl
obj.ChngOrientationLandscape

rs.Open "select * from cheques where mata = '" & pro.Text & "' and status = '" & sta.Text & "'", con, 1, 3

If rs.RecordCount = 0 Then
MsgBox "No record found on query.", vbCritical, "Medrar"

Else
Set FullReport.DataSource = rs
Unload Me
FullReport.Show
End If

Set rs = Nothing

End Sub
*********
In this code, where should add it?
 
Private Sub cmdOK_Click()

----> insert code here

Set obj = New PrinterControl


Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
... and do not forget to add a print command to print out your report

Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Don't mind, i am some what confused, please update my code.
Thnx for Help alot
I am just stucked in that place
 
Code:
Private rs As New ADODB.recordset
Dim obj As PageSet.PrinterControl
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim prt As Printer

For Each prt In Printers
  If prt.DeviceName = "MyPrinterName" Then
    Set Printer = prt
    Exit For
  End If
Next


Set obj = New PrinterControl
obj.ChngOrientationLandscape

rs.Open "select * from cheques where mata = '" & pro.Text & "' and status = '" & sta.Text & "'", con, 1, 3

If rs.RecordCount = 0 Then
    MsgBox "No record found on query.", vbCritical, "Medrar"
   
Else
    Set FullReport.DataSource = rs
    Unload Me
    FullReport.Print
End If

Set rs = Nothing

End Sub

-> Change "MyPrinterName" to your network printer name



Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Run Time Error:438
Object Doesn't support this property or method

Shows Debug in Fullreport.print
 
I am just trying to help without any possibility to test myself at the moment.

As you are a programmer, you may try another syntax for the printing - eg.

Code:
printer.print Fullreport
printer.enddoc


Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Oh and by the way, if you are have VB service pack 4 or later applied (and you really, really should have), then you do not need the dreadful PageSet dll that you appear to be using. So you can use

Fullreport.Orientation = rptOrientLandscape

rather than

Set obj = New PrinterControl
obj.ChngOrientationLandscape
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top