End user printouts

computermat

Active member
Joined
Jun 17, 2007
Messages
28
Programming Experience
Beginner
(Did not know where to post this)

Hi, I am currently writing a booking system where a user will enter customer details, these will be stored in a database and a receipt will be printed to give to the customer to confirm the booking.

The printouts I need to produce will contain data from an active form and data from a database. How would I make a printable document that contains form fields like text from textboxes. If I cannot do this I have thought about saving the data to the database then printing it and using a lookup style document. Example, reads a customer number from the active form then looks this up on a database to return the data required for printing.

I have put an image below showing what functions I will want to use. Between the < > will be data from the active form and between ( ) will be from a database.
letter.png
 
Hi, in relation to the start of this thread I might not have phrased it good. At the end of the day I just want to know is there a way to show the text from a text box on a report and then print that.

:confused: :confused: :confused: :confused:
 
Use Parameters

You can pass text as strings by using parameters in the report.

also, you can assign text to textboxes on the report directly.
Set textbox text from viewer:
VB.NET:
        Dim testReport As CrystalDecisions.CrystalReports.Engine.TextObject
        Dim testText As CrystalDecisions.CrystalReports.Engine.TextObject
        testText = CType(Traveler.ReportDefinition.ReportObjects.Item("Text1"), CrystalDecisions.CrystalReports.Engine.TextObject)
        testText.Text = "this is it"

Parameters can be set as follows:

VB.NET:
        Dim MyReport As New yourReportName

        MyReport.SetParameterValue("ParameterName1", TextBox1.text)
        MyReport.SetParameterValue("ParameterName2", TextBox1.text)

I believe that is right, but I'm not on my code machine right now, let me know if you have trouble.
 
Hi, thank you very much for your reply. I have tried to use this code but i don't know where to put it. I tried to use it on my form report which contains the a report viewer in the load sub of the form but it throws the error that crystal objects are not declared. If its a lot of code could you post project files of vb as a zip.

I have the academic version of VS Studio 2005 but have never used crystal reports before i dont even know if i have got it.

You will have to bare with me on this topic becuase i am new to .net and have very limited knowledge of the report builder.

Thanks again.
 
VB.NET:
        Dim testReport As As New YourReportName
        Dim testText As CrystalDecisions.CrystalReports.Engine.TextObject
        testText = CType(Traveler.ReportDefinition.ReportObjects.Item("Text1"), CrystalDecisions.CrystalReports.Engine.TextObject)
        testText.Text = "this is it"

Sorry, the first line was wrong. You should put this code where ever you are printing or displaying the report. On the viewer form is fine.
Since you are VB2005 you may have to search on some of the keywords to get exact code.
 
Hi, thanks for replying again, i have been looking around the internet and found that the standard version of VS2005 does not contain crystal reports.

Also seen crystal reports website but i dont know which version to get if any. Are there any alternatives to using crystal to get text from a textbox. Anything built into vs2005 standard.
 
If i cannot link to textboxes is there a way i can get a customer number from my form then look that up on a SQL table
 
Back
Top