feesu
asked on
Subreports Datasource
Experts,
I am using a crystal report designer imported into VB from an existing report, loading in crystal viewer.
My report uses sub reports. I am setting the reports datasource at rumtime, how can i set the datasource of the subreport at runtime?
I am using a crystal report designer imported into VB from an existing report, loading in crystal viewer.
My report uses sub reports. I am setting the reports datasource at rumtime, how can i set the datasource of the subreport at runtime?
link your subreport to your datasource. you do this in the main report. right-click on the subreport and set the link to your datasource there.
ASKER
Hi dkDeveloper,
I am using crystal reports 9, VB 6..
Hi zephyr hex,
I wanted to link it at runtime by code.
I am using crystal reports 9, VB 6..
Hi zephyr hex,
I wanted to link it at runtime by code.
sorry - no experience with the older versions.
dK
dK
This isn't what you've asked, but I had tons of trouble linking tables together with multiple links. The crystal example/documentation/help doesn't mention that the source and destination fields can be arrays.
Dim crTable1 As CRAXDRT.DatabaseTable
Dim crTable2 As CRAXDRT.DatabaseTable
Dim crDatabaseSourceField1(1) As CRAXDRT.DatabaseFieldDefin ition
Dim crDatabaseDestField1(1) As CRAXDRT.DatabaseFieldDefin ition
Set crTable1 = crReport.Database.Tables(i Table1)
Set crTable2 = crReport.Database.Tables(i Table2)
Set crDatabaseSourceField1(0) = crTable1.Fields(sSourceFie ld1)
Set crDatabaseDestField1(0) = crTable2.Fields(sDestField 1)
Set crDatabaseSourceField1(1) = crTable1.Fields(sSourceFie ld2)
Set crDatabaseDestField1(1) = crTable2.Fields(sDestField 2)
crReport.Database.Links.Ad d crTable1, crTable2, crDatabaseSourceField1, crDatabaseDestField1, crJTLeftOuter, crLTLookupParallel, False, True
I never tried to create a sub-report via code.
Dim crTable1 As CRAXDRT.DatabaseTable
Dim crTable2 As CRAXDRT.DatabaseTable
Dim crDatabaseSourceField1(1) As CRAXDRT.DatabaseFieldDefin
Dim crDatabaseDestField1(1) As CRAXDRT.DatabaseFieldDefin
Set crTable1 = crReport.Database.Tables(i
Set crTable2 = crReport.Database.Tables(i
Set crDatabaseSourceField1(0) = crTable1.Fields(sSourceFie
Set crDatabaseDestField1(0) = crTable2.Fields(sDestField
Set crDatabaseSourceField1(1) = crTable1.Fields(sSourceFie
Set crDatabaseDestField1(1) = crTable2.Fields(sDestField
crReport.Database.Links.Ad
I never tried to create a sub-report via code.
By the way, I don't think there are many differences between the old and new via code. Or, at least I don't remember any. I wrote with CR8.5 and moved to XI just before deploying.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks you everyone for the help.
dylanyee,
The code you sent worked in vb6. But what do you put in the sub report name space? full path or a variable representing the report object?
dylanyee,
The code you sent worked in vb6. But what do you put in the sub report name space? full path or a variable representing the report object?
feesu, just put the sub-report name will do. Every sub-report must have a name when you create it. To change your sub-report name, right click your subreport->Format subreport->subreport->subr eport name.
If you could post some information around which version of both Crystal and VB you are running we probably supply some more definite answers, but until then check out this knowledgeBase entry to see if that helps:
http://support.businessobjects.com/library/kbase/articles/c2010275.asp
Good Luck!
dK