|
-
Aug 24th, 2005, 10:52 AM
#1
Thread Starter
Member
Crystal Report 9.0 and VB6
Hi All,
I know this question has been posted many times. But I could not get a specific answer for my confussion.
I am creating reports using Crystal. All is good until the stored proc (SQL 2000) requires a parameter.
How do I write a generic function in VB6 that will open the selected report and pass the required parameters. Would I still have to go through the ado connection stuff etc.?
RobbDog, I did see the link in your signature, but that does not answer my above question.
Also, is there any tool that will let me convert my Access reports to CR9 reports?
Thanx all for your help.
-
Aug 25th, 2005, 01:27 PM
#2
Re: Crystal Report 9.0 and VB6
 Originally Posted by ankeet1
How do I write a generic function in VB6 that will open the selected report and pass the required parameters. Would I still have to go through the ado connection stuff etc.?
Rather than messing about with CR parameters, I just pass it the result of a recordset that I've created based on an SQL query.
 Originally Posted by ankeet1
Also, is there any tool that will let me convert my Access reports to CR9 reports?
No, not that I know of. Those reports will all have to be converted manually.
-
Aug 25th, 2005, 01:59 PM
#3
Re: Crystal Report 9.0 and VB6
If you do use a generic function to open your report you will have to use the Parameters collection to add each parameter to the collection. Then set the DataSource and open. You will have to keep track of which report requires which parameters, etc.
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 
-
Aug 30th, 2005, 03:47 PM
#4
New Member
Re: Crystal Report 9.0 and VB6
lol...this may be late but it should work.
VB Code:
'===================================================================================
'Create the Crystal Reports Objects
'===================================================================================
If Not IsObject(oApp) Then
Set oApp = CreateObject("CrystalRuntime.Application")
End If
' CREATE THE REPORT OBJECT
'
'The Report object is created by calling the Application object's OpenReport method.
Dim Path
Dim reportname
Path = "**YOUR PATH**"
reportname = "**YOUR REPORT.rpt**"
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(oRpt) Then
Set oRpt = Nothing
End If
Set oRpt = oApp.OpenReport(Path & reportname, 1)
oRpt.MorePrintEngineErrorMessages = False
oRpt.EnableParameterPrompting = False
'Now we must tell the report to report off of the data in the recordset:
oRpt.DiscardSavedData
'Pass parameters to the report
'set up begin and end date to be the first and last days of the previous week
oRpt.ParameterFields(1).AddCurrentValue ***YOUR PARM***
Dim dbTable
' login to each of the report's tables
For Each dbTable In oRpt.Database.Tables
dbTable.SetLogOnInfo "**SERVER Connection**", "***DATABASE***", "**USER**", "**PASSWORD***"
Next
oRpt.ReadRecords
'====================================================================================
' Exporting the Crystal Report
'====================================================================================
outputPath = "**OUTPUT FILE PATH**"
outputfilename = "**OUTPUT FILE**"
Set fso = CreateObject("Scripting.FileSystemObject")
'delete final backup target file if it exists
If fso.FileExists(outputfilename & outputPath) Then
fso.DeleteFile outputfilename & outputPath
End If
ExportType = 31
'These lines collect the values passed from the calling HTML page for the export
'type and filename
'ExportOptions = oRpt.ExportOptions
'First we create an export options collection which allows us access
'to the exporting properties of the automation server.
oRpt.ExportOptions.DiskFileName = outputPath + CStr(outputfilename)
oRpt.ExportOptions.FormatType = CInt(ExportType)
'This line sets the file type that the report will be exported to. We
'use the value that we collected from the calling HTML page.
oRpt.ExportOptions.DestinationType = 1
'This line sets the destination of the exported file. 1 means that
'we are writing the file to disk.
On Error Resume Next
oRpt.Export False
If Err.Number <> 0 Then
'MsgBox "Error Occurred Exporting Report: " & Err.Description & Err.number
oRp = Nothing
oApp = Nothing
Else
If IsObject(oPageEngine) Then
Set oPageEngine = Nothing
End If
Set oPageEngine = oRpt.PageEngine
End If
End Sub
Edit: Added [vbcode][/vbcode] tags and indentation for clairty. - Hack
Last edited by Hack; Sep 9th, 2005 at 02:17 PM.
-
Sep 9th, 2005, 11:36 AM
#5
Thread Starter
Member
Re: Crystal Report 9.0 and VB6
Circusfit,
I just looked up your reply. I was caught up in a different project and now i am back to this project.
I will definitely give it a shot. THe way you have written the code, i am almost sure that this should be the solution to my question!
Thanks a lot.
-
Sep 9th, 2005, 02:18 PM
#6
Re: Crystal Report 9.0 and VB6
One thing. In the Err.Number section, you need to use Set to destroy the objects.
VB Code:
oRp = Nothing
oApp = Nothing
'needs to be
Set oRp = Nothing
Set oApp = Nothing
-
Sep 12th, 2005, 04:15 PM
#7
Thread Starter
Member
Re: Crystal Report 9.0 and VB6
VB Code:
Set oApp = CreateObject("CrystalRuntime.Application")
I get the following error at the above line:
Run-time Error 439.
ActiveX Component can't create object.
Probably, the app cannot find CrystalRuntime. Shouldn't it have been installed at the time of installation? We also have Crystal Viewer set up. Also, would this code NOT work with CR 11? I know my message title mentions CR 9, but last friday, we upgraded to CR11 (well, because of some tech issues, they will be down grading back to CR 9 next week, until they can find some permenant solution).
Thanks for the help!
-
Sep 13th, 2005, 08:13 AM
#8
Re: Crystal Report 9.0 and VB6
Crystal runtimes may or may not be automatically added to your setup and installation package. It depends on which one you are using. The P&DW does not.
Repackage your project and make sure those runtimes are included.
-
Sep 14th, 2005, 09:24 AM
#9
Thread Starter
Member
Re: Crystal Report 9.0 and VB6
I am actually getting the error when I am compiling the project. What reference file(s) need to be included in vb6?
Excuse me for being a pain, but some how the code is just not work successfully.
Thank You.
-
Oct 6th, 2005, 10:07 AM
#10
Re: Crystal Report 9.0 and VB6
I think you need : craxdrt.dll
[EDIT] OOps.. lol I was searching, then posted an answer.. nice! Pay attention! [/EDIT]
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Oct 7th, 2005, 07:46 AM
#11
New Member
Re: Crystal Report 9.0 and VB6
When you install the crystal, it autometically adds reference in VB. So it you go to the reference list, you should find one for Crystal.
-
Oct 7th, 2005, 01:52 PM
#12
Re: Crystal Report 9.0 and VB6
 Originally Posted by tansarbh
When you install the crystal, it autometically adds reference in VB. So it you go to the reference list, you should find one for Crystal.
True, and you should also find the components for Crystal Reports under the Components section on the VB IDE.
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
|