|
-
Jan 8th, 2006, 08:43 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] vb6 crystal reports
OK, i was trying to do a report in crystal reports. mind u all, i've never done reporting thru any data reports except for thru excel.
now it turns out that i have absolutely no idea on creating reports without using a data environment.
i am using ado connection. i have the recordset ready. i do have the report ready too. just that i dont know how to bind the recordset to the fields in the report.
VB Code:
CrystalReport1.Database.SetDataSource dbRS
says error 9, subscript out of range.
does anybody have a step by step tutorial on this? this is urgent and i am ready to sleep. sorry, not even have time for a search right now.
thank you.
-
Jan 8th, 2006, 08:47 AM
#2
Re: vb6 crystal reports
What CR version do you use?
-
Jan 8th, 2006, 08:51 AM
#3
Re: vb6 crystal reports
Here is an example of using the CR Viewer control but it shos how to bind your recordset as you were missing some parameters.
Also, you need to set up a ADO connection in the CR IDE for your report. This is how you would bind the textboxes to your fileds, do aggregrate funtions, etc.
VB Code:
Option Explicit
'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
'Add reference to Crystal Reports Viewer Control
'Add reference to Microsoft ActiveX Data Objects 2.x Library
'oCnn = current open ADO connection object
Private Sub Command1_Click()
Dim oApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Dim oRs As ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT * FROM Table1"
Set oRs = New ADODB.Recordset
Set oRs = oCnn.Execute(sSQL)
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
oReport.Database.SetDataSource oRs, 3, 1
crvMyCRViewer.ReportSource = oReport
crvMyCRViewer.ViewReport
End Sub
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 
-
Jan 8th, 2006, 08:58 AM
#4
Re: vb6 crystal reports
I don't think that will work for mebhas - he's most likely using CR8 (8.5 or maybe even 7) - CrystalReport1 tells me it's a control that was last included as of v 8.5. Your sample is suitable for post CR8.5 products.
-
Jan 8th, 2006, 09:00 AM
#5
Re: vb6 crystal reports
Yes, my example is based off of my version - 8.5 developer. But I mostly wanted to show how to set the .SetDataSource correctly. Wasnt even sure if he is using a preview or not. Just a bonus.
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 
-
Jan 8th, 2006, 11:38 AM
#6
-
Jan 8th, 2006, 12:20 PM
#7
Addicted Member
-
Jan 8th, 2006, 10:35 PM
#8
Thread Starter
Frenzied Member
Re: vb6 crystal reports
thanx to everybody who posted. i finally did make it work. it was a bit tricky but i did get it to work.
i am using cr9. i used robdog's code. not from here but i found it in one of his sigs.
i did use the cr9 help files to create the initial report first. then used robdog's code. but i did use a
VB Code:
crViewer.DiscardSavedData
so that the report didnot show any previously saved data.
and again thanx to all.
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
|