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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB6 to change DB location of subreport

Status
Not open for further replies.

sjulian

Programmer
Aug 15, 2000
56
US
I have a VB6 app that allows user to select, view and print Crystal Reports developed in 8.5. My app worked fine until I put together a report with a subreport. I used the code below which I found in Crystal's knowledgebase, but when I step through the lines, I find that the .DataFiles are pulling from the main report, not the subreport.
Code:
If SubReportExists = True Then
  For SubReportLoopCount = 0 To SubReportCount
    .SubreportToChange = .GetNthSubreportName(SubReportLoopCount)
    TabCount = .RetrieveDataFiles
    For FilesLoopCount = 0 To (TabCount - 1)
      strTemp1 = .DataFiles(FilesLoopCount)
      SlashPos = InStrRev(strTemp1, "\")
      strTemp2 = Right$(strTemp1, Len(strTemp1) - SlashPos)
      If LCase(Right$(strTemp2, 3)) = "smd" Then
        .DataFiles(FilesLoopCount) = PathtoData + strTemp2
      End If
      If LCase(Right$(strTemp2, 3)) = "mkd" Then
        .DataFiles(FilesLoopCount) = PathtoApptData + strTemp2
      End If
    Next FilesLoopCount
  Next SubReportLoopCount
End If
.SubreportToChange = ""
Before arriving at the above code, my program has set the DB location for the main report using nearly the same procedure. After the .SubreportToChange statement, the program tells the report to run.
I've banged my head against the wall for a couple of weeks now (off & on) and appreaciate any help you can offer. :^)
 
OOPS! I forgot one thing. I have checked the .SubreportToChange statement and it is picking up the correct name of the subreport.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top