|
-
Dec 13th, 2004, 11:17 PM
#1
Thread Starter
Hyperactive Member
-
Dec 13th, 2004, 11:35 PM
#2
Re: Crystal to show recordset
If you are just trying to pass a pre-created CR parameter...
Code:
Dim crxApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Set crxApp = New CRAXDRT.Application
Set oReport = crxApp.OpenReport(App.Path & "\MyReport", 1)
oReport.ParameterFields.Item(1).ClearCurrentValueAndRange
oReport.ParameterFields.Item(1).AddCurrentValue CStr(oRs!Name)
But it looks like you are trying to pass a recordset to a report? This will do it.
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 
-
Dec 14th, 2004, 09:48 PM
#3
Thread Starter
Hyperactive Member
Re: Crystal to show recordset
Thanks RobDog888.
Is this will automatically assign a fields in Crystal report?
-
Dec 14th, 2004, 10:11 PM
#4
Re: Crystal to show recordset
No, this will populate your already made report (bound/unbound fields). Say your
report has a Product Name textbox that is bound to a table's field Product_Name.
In you code that creates and populates the recordset, you select the same field
Product_Name and it will populate that control. The beuty of it is that your report
does not have to be connected to the database because the recordset is actually
the database.
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 
-
Dec 17th, 2004, 10:04 PM
#5
Thread Starter
Hyperactive Member
Re: Crystal to show recordset
Thanks a lot RobDog888
-
Dec 13th, 2005, 11:18 AM
#6
Hyperactive Member
Re: Crystal to show recordset
Hi,
i am new to crystal reports. and this thread helps me lot.
i want to pass a value as a parameter to crystal report which is selected in my vb application combo box.can i do this.If so please tell me.
i was created one crystal report with parameter StaffID.
which is a field in StaffDetails table. i want to pass the parameter StaffID from my vb application without prompting.
thanks a lot
wizkid
my code is :
Private Sub ViewReport_Click()
'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
Dim oApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Dim oRs As ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT * FROM StaffDetails"
Set oRs = New ADODB.Recordset
Set oRs = db_conn.Execute(sSQL)
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt")
oReport.Database.SetDataSource oRs, 3, 1
crvMyCRViewer.ReportSource = oReport
crvMyCRViewer.ViewReport
Dim StaffID As CRAXDRT.ParameterFieldDefinitions
Dim cpar As CRAXDRT.ParameterFieldDefinition
oReport.EnableParameterPrompting = False
oReport.ParameterFields.GetItemByName("StaffID").AddCurrentValue "combo1.text"
End Sub
but it is giving some error message Invalid name.
-
Jan 30th, 2006, 10:32 AM
#7
Hyperactive Member
Re: Crystal to show recordset
Hi RobDog888,
please help me!!!
your code is working fine.
but my problem is..
i am not getting the select * from table query values on table
i was already created the report newreport.rpt.it is a blank report.
and i want the query result when i press command9 button.
nearly from 3 weeks i working on this report
please give me some solution
Private Sub Command9_Click()
Dim oreport As CRAXDRT.report
Dim oapp As CRAXDRT.Application
Dim oRs As Recordset
Dim sSQL As String
Set oRs = New Recordset
Set oRs = db_conn.Execute("SELECT * FROM table")
Set oapp = New CRAXDRT.Application
Set oreport = oapp.OpenReport(App.Path & "\newreport.rpt", 1)
oreport.Database.SetDataSource oRs, 3, 1
CRViewer91.ReportSource = oreport
CRViewer91.ViewReport
End sub
thank u
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
|