×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Setting Table Location in Subreports

Setting Table Location in Subreports

Setting Table Location in Subreports

(OP)
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

RE: Setting Table Location in Subreports

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
http://www.kenhamady.com/

RE: Setting Table Location in Subreports

(OP)
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

RE: Setting Table Location in Subreports

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
http://www.kenhamady.com/

RE: Setting Table Location in Subreports

(OP)
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

RE: Setting Table Location in Subreports

(OP)
You are the best!

This works perfectly:

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

Thanks much!

Bob G

RE: Setting Table Location in Subreports

(OP)
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

RE: Setting Table Location in Subreports

I found that only the following would work

Dim crxSubreport as CRAXDRT.SubreportObject

Set crxSubreport = Report.Subreport1

crxSubreport.OpenSubreport.Database. (etc)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close