?
Solved

subreports and vb

Posted on 2003-03-13
19
Medium Priority
?
579 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:davoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 4
  • +1
19 Comments
 
LVL 1

Expert Comment

by:Chess
ID: 8127815
Did you pass in the connection information to the sub-report?
0
 

Expert Comment

by:costashh
ID: 8127835
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 8129792
listening
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

Expert Comment

by:costashh
ID: 8130020
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
 
LVL 1

Author Comment

by:davoman
ID: 8131910
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 8132704
Show the code you are using to call the reports.

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8135417
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 8136540
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
 
LVL 1

Author Comment

by:davoman
ID: 8193908
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
 
LVL 1

Author Comment

by:davoman
ID: 8193997
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
 

Expert Comment

by:costashh
ID: 8194073
Give the points to you!

I wish you the very best!
0
 
LVL 1

Author Comment

by:davoman
ID: 8194082
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
 

Expert Comment

by:costashh
ID: 8194116
Try doing separate reports!
1 report + 1 subreport = 2 separate reports!

my advice! :)
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 525 total points
ID: 8195984
How are you changing the subreport?  You may have to discard saved data for the mainreport and for the subreports.

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8235113
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
 
LVL 1

Author Comment

by:davoman
ID: 8235184
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 8235466
What are you passing for strpath1?

mlmcc
0
 
LVL 1

Author Comment

by:davoman
ID: 8235477
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 8279014
Glad I could help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question