I used that already but I got the following error:
Object reference on set to an instance of an object
Main Topics
Browse All TopicsHi..
I have a crystal report (crsSTUD) which designed depends on the database,
and I have a form (frmSTUDENT) contains on some textboxes which taking its data from the database table (STUDENT) , and print button,
what I want is when the (txtS_ID) Is filled by student ID and the press print button
to print the crystal report, the print dialog will show direct without showing the crystal report,
I'm using the following code but I couldn't complete it
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I dont think that is possible. You can either display the report and let the user print or you can directly print to a printer without any user interaction. One option is to use the PrintDialog to let user select a printer
http://msdn.microsoft.com/
If that does not help, you can use WMI to retrieve a list of all installed printers and then show a form to let the user select the printer.
http://www.dotnetcurry.com
I solve that error now .. it was from adp variable,
now the print problem..
I want to display the print dialog to choose the printer and print the specific record as I mentioned in my question..
I mean.. when (txtS_ID) is filled with ID, and press print .. it will print only the record that has the same ID..
if I put
rpt.PrintToPrinter(1, False, 0, 0)
it will print the whole records and without showing the print dialog
Here are some resources about parameters
http://www.codeproject.com
http://vb.net-informations
http://www.thescarms.com/d
http://www.codeproject.com
http://aspadvice.com/blogs
this is the code:
Dim adp As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
Dim rpt As New crsSTUD
Try
CMD.CommandType = CommandType.Text
CMD.CommandText = "SELECT * FROM STUDENT WHERE S_ID = '" + Me.txtS_ID.Text + "'"
adp.SelectCommand = CMD
CMD.Connection = CON
ds.Clear()
adp.Fill(ds, "STUDENT")
rpt.SetDataSource(ds)
rpt.PrintToPrinter(1, False, 0, 0)
Catch
'Display error message, if any
UnhandledExceptionHandler(
End Try
and as I said before ... I want to print it through the print dialog to choose the printer first
As i suggested previously, there are three options you have
1) Let the user print from the report viewer using the print button.
2) Print to the default printer using the PrintToPrinter without user interaction.
3) Retrieve(using WMI for example) and display a list of printers to user allowing them to choose a printer and then print to that printer.
Business Accounts
Answer for Membership
by: CodeCruiserPosted on 2009-07-16 at 02:16:23ID: 24867607
You would use the rpt.PrintToPrinter method to directly print the report without displaying it
objects.co m/business objectsxi/ en/ en/Crys talReports _dotNET_SD K/crystalr eports_net _doc/doc/ c rsdk_net_d oc/html/ cr lrfreportd ocumentcla ssprinttop rintermeth odtopic.ht m
http://devlibrary.business