VB 6.0 - crystal report viewer - Asked By Kaleem Khan on 05-Jul-08 09:23 AM

hi,

using vb6 + crystal report + oracle

how to open crystal report using crystal report viewer


Reply - alice johnson replied to Kaleem Khan on 05-Jul-08 12:10 PM

First  Open Components from the Projects Menu of VB6

Then select the Controls Tab & then
select Crystal Report Control 4.6
this will give you the correct reference to the control

In code you can do the following

    Dim crptRpt As CrystalReport

    crptRprt.ReportSource = crptReport
    crptRprt.ReportFileName = "diet.rpt"
    crptRprt.Action = 1 'This bit opens the crystal report file

This is the bare minimum needed to get going AND you can only use
reports created in the 4.6 version of the designer.

Reply - alice johnson replied to Kaleem Khan on 05-Jul-08 12:13 PM

 1. Create a NEW Standard Exe in VB (I use VB6)

2. Click Project, click References and select:
 (I use Crystal 9)
Crystal Report Viewer Control 9 --- Crystal Reports 9 ActiveX Designer Design and Runtime Library
Crystal Reports 9 ActiveX Designer Run Time Library
Click OK

 3. Click Project, click Components and select:
 Crystal Report Viewer Control 9 Click OK (this will add a small CRViewer9 icon under the General tab on your ToolBox

4. Name your form: frmMain...
put two command buttons on it
name one command button: cmdYourReportName
> ---change its caption to: Y&our Report Name
> ---name the other command button: cmdExit
> ---change its caption to: E&xit
> ---rightclick on the form, select View Code and add this code:
>
 Private Sub cmdExit_Click()
 Unload Me
 End
 End Sub

 Private Sub cmdYourReportName_Click()
 frmYourReportName.Show
 End Sub

 5. Add a new form to your project...name it: frmYourReportName
> ---change the WindowState to: 2 - Maximized
> ---double-click the CRViewer9 icon (under the General tab on your ToolBox)
> ---that just added a viewer to frmYourReportName
>
6. Change the (Name) of this viewer from CRViewer91 to: YourReportName
> ---put a command button on frmYourReportName ---move it to: LEFT 7000 TOP 0 (that will place it in a good position when you run the report)
> ---name it: cmdExitToMain
> ---change the caption to: E&xit to Main
8. Rightclick viewer and select View Code
> ---in the code window, paste this code:
>
 Private Sub cmdExit_Click()
> Unload Me
> End Sub
>
 Private Sub Form_Load()
 Dim Appl As New CRAXDRT.Application
 Dim Report As New CRAXDRT.Report
 YourReportName.Top = 0
 YourReportName.Left = 0
 YourReportName.Height = 12336
 YourReportName.Width = 15408
 Set Report = Appl.OpenReport("Y:\Reports\YourReportName.rpt")
 YourReportName.ReportSource = Report
 YourReportName.ViewReport
>End Sub
>
> ***Obviously, you need to use the correct path and file name for YOUR report***
>
9. Close these forms.
>
 10. Click Project, select Project1 Properties.
> ---change the Project Name to: Toms_Wonderful_Program
> ---change Startup Object to: frmMain
11. SAVE
>
 12. Run the program
> ---once it is up, click the "Your Report Name" command button
> ---your report will run (it will ask for parameters is needed)
> ---to close it, click the "Exit to Main" command button
>
13. Just add new command buttons (to frmMain) for each new form with a CRViewer (remember to change the names accordingly) for each report you want the others to access.

Will this help you:

Go throught this:

http://www.tech-archive.net/Archive/VB/microsoft.public.vb.crystal/2005-10/msg00063.html

hi - alice johnson replied to Kaleem Khan on 05-Jul-08 12:17 PM

You can also go through these links:

http://www.vbmysql.com/articles/vb6-mysql/using-mysql-visual-basic-6-and-crystal-reports-9

Reply - alice johnson replied to Kaleem Khan on 05-Jul-08 01:20 PM
create Crystal Report in Visual Basic 6.0 ,Follow this steps:
1. Start a new project in Visual Basic 6.0.

2. Go to the Project Menu, choose More Active X Components, Data

Environment. This takes you into the data environment.

3. Go to properties of the DataEnvironment1 and change the name to

Xtremedb.

4. Underneath the Xtremedb environment there is another icon that says

Connection1, right mouse click and pick properties. This pulls up the data

link properties dialog box.

5. Choose Microsoft OLE DB Provider for ODBC Drivers.

6. Click on the next button.

7. Choose your datasource from the dropdown box that is labeled use data

source name.

8. Press the OK button.

9. Right mouse click on the Connection1 again but this time choose Add

Command.

10. Right mouse click on the Command1 icon and pick properties.

11. For Command Name Type Employee, keep the Connection as the same.

12. For Source of Data:

Database Object – choose table

Object Name – Employee

Choose OK

Create the report

1. Open the Crystal Reports designer.

2. Under the File Menu, New, Custom Report, SQL/ODBC. This will pull up

the Logonserver dialog box.

3. Pick Active Data [ADO], then OK.

4. This pulls up the Select Data Source dialog box, select your datasource

from the dropdown box then press the Next button

5. Fill in your UserName and Password if needed then press the Finish button

6. The Choose SQL table dialog box comes up, pick ADO

7. This allows you to insert the fields on to the report.

8. Once you have placed all of the desired fields on the report, Save it as

Adotest.rpt

Hope this will help you
You can also refer thsi LInks for reference
http://training.nic.in/courseware/VB%20Files/presentations/Reports.pdf
http://resources.businessobjects.com/support/communitycs/TechnicalPapers/cr_ocx_dataenvir.pdf?recDnlReq=Record&dnlPath=cr_ocx_dataenvir.pdf

Happy coding takecare

tutorial - sundar k replied to Kaleem Khan on 05-Jul-08 01:31 PM

check the below link for a step by step tutorial, hope it helps!

http://www.vb6.us/tutorials/using-crystal-reports-vb6-tutorial