Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1216
  • Last Modified:

VB6 -> Crystal Reports: Subreport parameter prompt for link field

I've recently upgraded a VB6 application from Crystal 6 to Crystal 10. I'm now having problems running several reports which worked fine with Crystal 6.

The problem reports are those that have subreports (all the others work fine). Here's what happens.

I open a DAO dataset (rsData) and pass this to the main report

Set rsData = gdbHotel.OpenRecordset("SELECT keyItinerary, StartDate <etc ...> FROM tblCustItinerarys WHERE keyFBooking = 1", dbOpenDynaset)

With cryReport
    .Database.SetDataSource rsData
    .Database.Tables.Item(1).SetPrivateData 3, rsData
End With

I then do the same for the subreport.

Set rsDataGuest = gdbHotel.OpenRecordset("SELECT keyFItinerary, Title, Forename, Surname FROM tblCustGuests WHERE keyFBooking = 1;, dbOpenDynaset)

   For Each crSec In cryReport.Sections
        For iCount = 1 To crSec.ReportObjects.Count
            If crSec.ReportObjects.Item(iCount).Kind = crSubreportObject Then
                Set crSub = crSec.ReportObjects.Item(iCount)
                If crSub.SubreportName = "Guests" Then
                    Set crySubReport = crSub.OpenSubreport
                    crySubReport.Database.Tables.Item(1).SetPrivateData 3, rsDataGuest
                End If
            End If

(Code isn't particularly efficient, but it's always worked)

In this example the main report has a list of itineraries (the report is per itinerary), with the primary key: keyItinerary. This links to the Guests subreport on the field keyFItinerary. So the report has the link correctly established, and if you run the report in Crystal it works fine.

When you run it in VB, however, it prompts for the subreport parameter (Pm-dao.keyFItinerary) that the link is based on. If you give it a value, the report opens. The main body of the report is fine, but the sub-report will only have data for the value of keyItinerary that was manually input at the prompt. So, if the report has multiple pages, only one page will be correct. I'm passing the Guests subreport the correct data, it has all values of keyItinerary that could possibly be needed based on the data i'm passing the main report.

Hope that's clear ... it's early so i've done my best!

Any questions, let me know.
1 Solution

When linking your subreport, do you link it on "?@keyFItinerary" or "?Pm-?@keyFItinerary". It should be "?@keyFItinerary".

Crystal changed the interface with CR9 and 10.
Look at these examples


jonnyboy69Author Commented:
Thanks for your help. I'd already checked that Spykair, but thanks again. The reports were working fine both with the v6 viewer and within Crystal (regardless of version).

And thanks mlmcc. I did have to make a couple of code changes to get them running in the first place, but nothing that caused/affected this problem, so I don't think it was related to interface changes.

I can only think it's a problem with running v6 reports within the v10 viewer as i've rebuilt the reports from scratch, EXACTLY the same ... and now they're running fine.

Will get the topic closed now ...

Closed, 500 points refunded.

Community Support Moderator
Experts Exchange

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now