|
-
Nov 21st, 2000, 11:52 PM
#1
Thread Starter
Hyperactive Member
Hi team
I want to dynamically create an RS and then set the Crystal to look at it with "Database.SetDataSource myRS" (I'm Using the Crystal Reports Designer). But it doesn't work. It seems that Crystal is looking for a table rather than an RS. In DAO I could have created a table on the fly, but I can't see how to do that with ADO. Any bright ideas?
-
Nov 22nd, 2000, 09:49 AM
#2
Hyperactive Member
Here's an example of how I set a recordset to a report. I have a form named frmReport which contains a crystal report viewer control (crvCommon).
Code:
Dim rstCurrent As ADODB.Recordset
Dim strSql As String
Dim Report1 As rptAdjuster
strSql = "SELECT Adjuster.client_num, TRIM(Adjuster.adj_last)+', '+ TRIM(Adjuster.adj_first) as Name, Company.comp_name, Company.city "
strSql = strSql & "FROM openclose!company INNER JOIN openclose!adjuster "
strSql = strSql & "ON Company.comp_id = Adjuster.comp_id ORDER BY name"
Load frmReport
Set rstCurrent = New ADODB.Recordset
rstCurrent.Open strSql, fCnn1, adOpenForwardOnly, , adCmdText
Set Report1 = New rptAdjuster
Report1.Database.SetDataSource rstCurrent
frmReport.crvCommon.ReportSource = Report1
frmReport.crvCommon.ViewReport
frmReport.crvCommon.Visible = True
frmReport.Show
Hope this helps.
-
Nov 22nd, 2000, 08:31 PM
#3
Thread Starter
Hyperactive Member
Thanks Derick
From freewilly re dynamically set CR record source
-
Nov 23rd, 2000, 05:36 AM
#4
Fanatic Member
dcarlson,
I am having trouble with your code, it complains about the rptAdjuster data type in the line
Code:
Dim Report1 As rptAdjuster
I am using Crystal reports 8, would this have something to do with it, what version are you using.
-
Nov 23rd, 2000, 10:16 AM
#5
Hyperactive Member
rptAdjuster is the name my report. You need to create a report and replace rptAdjuster with the name of your report.
-
Nov 25th, 2000, 06:37 PM
#6
Fanatic Member
rptAdjuster?
Dcarlson,
I can't get your code to work either due to the rptAdjuster datatype. How did you reference rptAdjuster? I tried to add a reference to my report, but it didn't work. Please give a little more details.
-
Nov 27th, 2000, 09:42 AM
#7
Hyperactive Member
You need to create report using the Crystal Report Designer Component within VB. You can do this by clicking on the Project menu and Add Crystal Reports 8. In my case, I named my report rptAdjuster and set an Object variable to that report. Replace rptAdjuster with the name of your report.
Code:
Dim Report1 as YourCrystalReport
If you want examples look under
C:\Program Files\Seagate Software\Crystal Reports\Samples\Code\Visual Basic
-
Nov 27th, 2000, 01:49 PM
#8
Fanatic Member
Derrick,
Thanks for the follow-up. I guess I'm having a problem because I don't have Crystal Report 8. I only have version 4.6 which shipped with Visual Studio.
However, I think I can figure out a solution to my problem.
Thanks again.
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
|