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

Very new to this VB stuff

Status
Not open for further replies.

RGoldthorpe

Technical User
Aug 10, 2001
83
GB
Hello

I am having all sorts of fun and games going trying to get printing to work on a crystal report viewer.

I have learnt about the common dialog showprinter to select the printer you want to be able to print to so I have created a button for the user.

However all it seems to do for me is change the default printer but it doesnt seem to print to the printer it makes default anyway always it only prints to the old default.

This combined with the fact I do not want the printer the users selected to be windows default printer after they have finished printing is proving to be a pain to me.

Here is my code.

Private Sub Command1_Click()
With CommonDialog1
.CancelError = True
.PrinterDefault = True
.ShowPrinter
End With

CRViewer1.PrintReport
End Sub

All help is very gratefully recieved

Rach
 
The code below is for a form with a drop down list (cmbPrinter) of all available printers, and a portrait/landscape radio set (OptOrientation) - Plus OK and Cancel buttons...see if you can get anything useful out of it...

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOK_Click()

Dim prtPrinterSet As Printer

For Each prtPrinterSet In Printers
If cmbPrinter.Text = prtPrinterSet.DeviceName Then
Set Printer = prtPrinterSet
If Me.optOrientation(0) = True Then
Printer.Orientation = 2
Else
Printer.Orientation = 1
End If
End If
Next
frmGraph.Print_OK = True
Unload Me

End Sub

Private Sub Form_Load()
Dim prtPrinter As Printer

frmGraph.Print_OK = False

For Each prtPrinter In Printers
cmbPrinter.AddItem prtPrinter.DeviceName
If prtPrinter.DeviceName = Printer.DeviceName Then
cmbPrinter.Text = prtPrinter.DeviceName
End If
Next

If cmbPrinter.Text <= &quot; &quot; Then
MsgBox &quot;No default printer set up. Cannot print report&quot;
Unload Me
End If

End Sub
 
Thanks Bloo bird

What you sujested I have adapted and it works

It sets the printer as the one selected (Purchase)from the combo box now I know its me but when I tell it to print the report using

crviewer.printreport

it comes up with another print box after that saying it is going to print it to ISD (the worng printer I am really stumped.

Please help

Rachel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top