Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Table Location in Subreports 1

Status
Not open for further replies.

bobgsysop

Programmer
Nov 3, 2000
25
US
Using VB6, CR8 RDC, and Btrieve database files.

I set the location of my tables thus:

strParameters = gMyDatabaseName & "\oeordhdr.btr"
Report.Database.Tables(1).SetTableLocation strParameters, "OEORDHDR_SQL", " "


Where gMyDatabaseName has the full path to the database.

My report has a subreport in it, and I can not figure out how to set the table location for the files in the subreport.

Any help would be certainly appreciated!

Regards,
Bob Goldberg
 
The subreport is an object within the main report. I think it would look something like:

Report.Subreport.Database.Tables(1).... Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Hi Ken-

Thanks for the response. I had tried Report.Subreport.Database.Tables(1).... with no luck.

I found that you have to drill down through the sections of the report and find each subreport, open each subreport, and set the locations as if each was a report in itself.

'Get the sections from the Main report
Set crxSections = Report.Sections
'Go through each section in the main report...
For Each crxSection In crxSections
'Get all the objects in this section...
Set crxReportObjects = crxSection.ReportObjects
'Go through each object in the reportobjects for this section...
For Each ReportObject In crxReportObjects
'Find the object which is the SubreportObject
If ReportObject.Kind = crSubreportObject Then
'Found a subreport, now get a hold of it
Set crxSubreportObj = ReportObject
'Open the subreport and treat it as any other report
Set crxSubreport = crxSubreportObj.OpenSubreport
'Get the Tables collection for the subreport
Set crxTables = crxSubreport.Database.Tables
'Get the first table from the Tables collection
Set crxTable = crxTables.Item(1)
crxTable.SetTableLocation strParameters, "OEORDBLD", " "
End If
Next ReportObject
Next crxSection

Best regards,
Bob G
 
It appears that not all subreport properties are available from the main report. It is also different if you are using RPT vs DSR.

However, I thought the looping searches were only needed when you don't know the name of the subreport you are trying to set.

Of course, I never argue with an approach that works. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Hi Ken-

>>However, I thought the looping searches were only needed when you don't know the name of the subreport you are trying to set.

You know, I didn't actually try to set the table locations by referencing the sub report by name - I'll try that now and get back to you, as that would be a quicker method!

Thanks!
Bob G
 
You are the best!

This works perfectly:

Report.OpenSubreport "PullDetailReport.rpt"
Report.Database.Tables(1).SetTableLocation strParameters, "OEORDBLD", " "

Thanks much!

Bob G
 
Oops -

The correct code should read:

Dim crxSubreportObj As CRAXDRT.SubreportObject


Set crxSubreport = Report.OpenSubreport("PullDetailReport.rpt")
crxSubreport.Database.Tables(1).SetTableLocation strParameters, "OEORDBLD", " "


Regards,
Bob G
 
I found that only the following would work

Dim crxSubreport as CRAXDRT.SubreportObject

Set crxSubreport = Report.Subreport1

crxSubreport.OpenSubreport.Database. (etc)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top