subreports and vb

Hi using the crystal report viewier control in VB i'm opening up crystal reports from vb without a problem however can u use subreports with this methods. i have a subreport on some of the reports and get the message saying file not found. yet they open up ok in crystal

thanks in advance
LVL 1
davomanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChessCommented:
Did you pass in the connection information to the sub-report?
0
costashhCommented:
try to put the service pack from Crystal.
http://support.crystaldecisions.com/fix/hot/si75/?ref=default.asp_selectlist

They say something about the viewer.
0
mlmccCommented:
listening
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

costashhCommented:
in this PDF are many issues about subreports in viewer http://ftp.crystaldecisions.com/webprod/hot_fixes/en/ce80win_en_sp1.pdf
That's why I presume that the SP1 might resolze the issue.

(what versions of viewer/CR you are using ?)
0
davomanAuthor Commented:
I am using vb 6,0 and crystal 8.5. The subreport has its own ADO connection as is linked via a field in the main report which i am calling
0
mlmccCommented:
Show the code you are using to call the reports.

mlmcc
0
davomanAuthor Commented:
Public Sub ShowReports(ByVal strquery As String, strpath As String)
On Error GoTo Error_check

Dim CRVAppl As CRAXDRT.Application
Dim CRReport As CRAXDRT.Report
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Set CRReport = Nothing


Set CRVAppl = New CRAXDRT.Application
Set CRReport = CRVAppl.OpenReport(strpath)
CRReport.DiscardSavedData


cn.ConnectionString = "Provider = SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;" & _
                        "Data Source=Server1;" & _
                        "Initial Catalog=FordContact"
cn.Open
rs.Open strquery, cn, adOpenKeyset

If rs.RecordCount > 0 Then
While rs.EOF = False
    CRReport.Database.SetDataSource rs
rs.MoveNext
Wend

Screen.MousePointer = vbHourglass

frmMainReports.CRViewer1.ReportSource = CRReport
frmMainReports.CRViewer1.ViewReport
frmMainReports.Show


Screen.MousePointer = vbDefault


frmMainReports.Left = (Screen.Width - frmMainReports.Width) / 2
frmMainReports.Top = (Screen.Height - frmMainReports.Height) / 2
Else
    MsgBox "There were no records to show or the report could not be created"
    Exit Sub
End If
Set CRReport = Nothing
Set CRVAppl = Nothing
Error_out:
Exit Sub

Error_check:

MsgBox "There has been and error. Please see the system administrator" & vbCr & vbCr & Err.Number & vbCr & Err.Description
Resume Error_out
End Sub
0
mlmccCommented:
If rs.RecordCount > 0 Then
While rs.EOF = False
   CRReport.Database.SetDataSource rs
rs.MoveNext
Wend

What is the above code trying to do?

You only need to set the datasource once.

mlmcc
0
davomanAuthor Commented:
mm seem to have got that bit wring mimcc.

However the above code opens up the main report fine its the subreport which will not open through the view. do i also have to pass the datasource through even though it does not changed and is all linked through the main report. I have tried service pack 1 but that has made no difference

0
davomanAuthor Commented:
DOH i was just being think. Hey why not use the open sub report method!!

Cheers anyway.

Dunno who to give the points to, any advice
0
costashhCommented:
Give the points to you!

I wish you the very best!
0
davomanAuthor Commented:
DOH no can do when me tells it to discard saved data i get file not found again

Has anyone got any spare hair i've just pulled mine out!!!
0
costashhCommented:
Try doing separate reports!
1 report + 1 subreport = 2 separate reports!

my advice! :)
0
mlmccCommented:
How are you changing the subreport?  You may have to discard saved data for the mainreport and for the subreports.

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
davomanAuthor Commented:
i am beggning to realise i also have to pass the date through the subreport. I though because it already had a datasource defined i would not have to do it with code
ho hum
0
davomanAuthor Commented:
Public Sub ShowSubReports(ByVal strquery As String, strpath As String, strpath1 As String)
'On Error GoTo Error_check

Dim CRVAppl As CRAXDRT.Application
Dim CRReport As CRAXDRT.Report
Dim crReportsub As CRAXDRT.Report
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set CRReport = Nothing


Set CRVAppl = New CRAXDRT.Application
Set CRReport = CRVAppl.OpenReport(strpath)
Set crReportsub = CRReport.OpenSubreport(strpath1)
CRReport.DiscardSavedData



cn.ConnectionString = "Provider = SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;" & _
                        "Data Source=Server1;" & _
                        "Initial Catalog=FordContact"
cn.Open
rs.Open strquery, cn, adOpenKeyset

If rs.RecordCount > 0 Then
'While rs.EOF = False
    CRReport.Database.SetDataSource rs
'rs.MoveNext
'Wend
Screen.MousePointer = vbHourglass

frmMainReports.CRViewer1.ReportSource = CRReport


frmMainReports.CRViewer1.ViewReport

frmMainReports.Show


Screen.MousePointer = vbDefault


frmMainReports.Left = (Screen.Width - frmMainReports.Width) / 2
frmMainReports.Top = (Screen.Height - frmMainReports.Height) / 2
Else
    MsgBox "There were no records to show or the report could not be created"
    Exit Sub
End If
Set CRReport = Nothing
Set CRVAppl = Nothing
Error_out:
Exit Sub

Error_check:

MsgBox "There has been and error. Please see the system administrator" & vbCr & vbCr & Err.Number & vbCr & Err.Description
Resume Error_out
End Sub

ammended the code to look like this but still getting file not found
0
mlmccCommented:
What are you passing for strpath1?

mlmcc
0
davomanAuthor Commented:
hotels.rpt the name of the subreport.

I've just got now it now. I needed to pass the datsource through as well and now it works at the mo. mind you i had it working before then broke it again :)
0
mlmccCommented:
Glad I could help

mlmcc
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.