|
-
Sep 10th, 2005, 06:35 AM
#1
Thread Starter
Hyperactive Member
calling report
Hi,
Please guide us how to call crystal report into visual basic.
ASM
-
Sep 10th, 2005, 11:43 AM
#2
Re: calling report
I have a short example in my signature - "VB6/Crystal Report Ex."
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 13th, 2005, 11:56 PM
#3
Thread Starter
Hyperactive Member
Re: calling report
Hi
I have gone through your example coding... and try accordingly
but i can not find crystal reports reference in vb6 project-Reference..
please guide me...
ASM
-
Sep 14th, 2005, 12:06 AM
#4
Thread Starter
Hyperactive Member
Re: calling report
Hi
I have gone trhough your example but I can not get project-reference
for crystal reports you have mention...
Thanks
-
Sep 16th, 2005, 02:30 PM
#5
Member
Re: calling report
Hi ASM,
Hope you are not frustrated by now!
I went thru the same questions that you have.
Here is my sample code:
VB Code:
Private Sub Command2_Click()
Dim path As String
Dim reportname As String
path = "ReportPath\"
reportname = "ReportName.rpt"
Dim oApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Dim ors As dao.Recordset
Dim ssql As String
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(path & reportname)
CRViewer91.ReportSource = oReport
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Couple things:
Make sure you have Crystal Viewer installed. I think there is one common viewer for any kind of reports.
Once you do that, include 'Crystal Viewer 9.0 ActiveX designers....' reference in to your vb project.
After above two steps, you will have access to CRAXDRT library.
Thanks RobDog for the code.
Ankeet.
-
Sep 16th, 2005, 02:34 PM
#6
Re: calling report
 Originally Posted by asm
Hi
I have gone trhough your example but I can not get project-reference
for crystal reports you have mention...
Thanks
The references are available if you have Crystal Reports installed. Do you have a copy of the program? The references might vary a little on newer versions of CR but should still be visible.
The CR Viewer control is only available if you have CR installeed on your system.
Your Welcome, ankeet1. Glad it has helped as it doesnt get much notice.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 21st, 2005, 09:40 AM
#7
Member
Re: calling report
RobDog,
Your code works well, I can open report i can even execute this line
VB Code:
oReport.Database.SetDataSource oRs, 3, 1
but, when the report opens, it still prompts me for parameters. How do i stop this?!!
Ankeet
-
Sep 21st, 2005, 09:58 AM
#8
Re: calling report
That is caused by the report file itself. Open it up on the Crystal Report designer, and remove the part that calls for parameters.
-
Sep 21st, 2005, 09:59 AM
#9
Re: calling report
Ok, in your report in Crystal Reports you must have created some parameters? You need to pass these parameters before you open the report using the Parameters collection.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 21st, 2005, 10:12 AM
#10
Member
Re: calling report
Yes,
when i created the reports, I did have a stored proc set as data source and that stored proc expects parameters.
There is no place else in the report which uses any of these parameters. I do have calculated fields (formulas) but they are calculated based on grouping and values from the stored proc.
Also,
robDog, can you point me to some place which demonstrates using the Parameters collection.
I followed one of the posts and tried to pass 'discrete' parameters in following way:
VB Code:
crParameterFieldDefs = oReport.DataDefinition.ParameterFields
But, when i type 'oReport.' there is no drop down list which means, i might need to include some more references. Which ones?
Your help is GREATLY appreciated!
Ankeet
-
Sep 21st, 2005, 11:46 AM
#11
Re: calling report
oReport is my Report object. There should be a Parameters collection right off of the Report object. DataDefinition is for using ttx files with CR.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 21st, 2005, 03:02 PM
#12
Member
Re: calling report
Guys once again!
A'ight, i fixed the previous issue of passing parameters. Now it does not ask me for param values. Below is the code.
Also, as you can see from the code, i use a WHILE loop to open multiple reports. Thats where the problem is - how do i open multiple reports (tabbed browsing)?
VB Code:
While Not de.rsdbo_spMES_GetSelectedReports.EOF
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\Reports\" & _
de.rsdbo_spMES_GetSelectedReports.Fields("CSName").Value)
' CALL the modReportViewer.
' Pass the report name, based on which the modReportViewer
' will call appropriate report wrappers and return a
' record set.
oReport.DiscardSavedData
'oReport.Database.SetDataSource ReportFetcher(de.rsdbo_spMES_GetSelectedReports.Fields("CSName").Value), 3, 1
' get the count of parameter fields in the current report
ParamCount = oReport.ParameterFields.Count
' loop for number times = param count.
' Also make sure EVERY STORED PROC SHOULD USE SAME NAME FOR PARAMETERS.
' ANY NEW PARAMETER SHOULD BE ADDED TO THE CASE STATEMENT.
For i = 1 To ParamCount
Select Case LCase(oReport.ParameterFields(i).ParameterFieldName)
Case LCase("@CurrentRepCompany")
oReport.ParameterFields(i).AddCurrentValue (gCompany)
Case LCase("@CurrentRepPlantID")
oReport.ParameterFields(i).AddCurrentValue (gPlantID)
Case LCase("@CurrentRepDepartmentID")
oReport.ParameterFields(i).AddCurrentValue (gDepartmentID)
Case LCase("@CurrentRepLineID")
oReport.ParameterFields(i).AddCurrentValue (gLineID)
Case LCase("@CurrentRepItemID")
oReport.ParameterFields(i).AddCurrentValue (gItemID)
Case LCase("@CurrentRepProdDate")
oReport.ParameterFields(i).AddCurrentValue (CDate(gBeginDate & " 00:00"))
Case LCase("@CurrentRepEndDate")
oReport.ParameterFields(i).AddCurrentValue (CDate(gEndDate & " 00:00"))
Case LCase("@CurrentUser")
oReport.ParameterFields(i).AddCurrentValue (gCurrentUserID)
End Select
Next i
' do not let the user refresh the data on the report.
' user can close the report and open it again.
crViewer.EnableRefreshButton = False
' display tabs.
crViewer.DisplayTabs = True
crViewer.TabIndex
crViewer.ReportSource = oReport
crViewer.ViewReport
Screen.MousePointer = vbDefault
de.rsdbo_spMES_GetSelectedReports.MoveNext
Wend
Thanx for your help!
Ankeet
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|