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

Calling subreport from vb

Status
Not open for further replies.

PawelTru

Programmer
Jul 18, 2002
24
0
0
US
I have a problem with a report which has 2 subreports.
When I try to run it from vb6 I get "Server has not yet been opened" error message.

The data is retrieved using SQL stored 3 stored procedures.

one for the main report and 1 for each of the sub reports.

the code that I am using in vb for the MAIN REPORT IS:

Set crxReport = crxApplication.OpenReport(RptName)
With crxReport
For Each dt In .Database.Tables
.VerifyOnEveryPrint = False
.DiscardSavedData
searchfor = "."
Location = CStr(dt.Location)
occurance = InStr(Location, searchfor)
sublocation = Mid(Location, occurance, Len(Location) - occurance + 1)
Location = frmLogin.dbname & sublocation
dt.SetTableLocation Location, "", ""
dt.SetLogOnInfo frmLogin.DBServer, frmLogin.dbname, frmLogin.DBSQLId, frmLogin.DBSQLPassword

Next
End With

FOR SUB REPORTS:

If (subreport <> &quot;&quot;) Then
Dim subrep() As String
subrep = Split(subreport, &quot;,&quot;)
Dim x As Integer

For x = 0 To UBound(subrep)
'Set mySub = crxReport.OpenSubreport(subreport)
Set mySub = crxReport.OpenSubreport(subrep(x))

With mySub
For Each dt In .Database.Tables
.VerifyOnEveryPrint = False
.DiscardSavedData
searchfor = &quot;.&quot;
Location = CStr(dt.Location)
occurance = InStr(Location, searchfor)
sublocation = Mid(Location, occurance, Len(Location) - occurance + 1)
Location = frmLogin.dbname & sublocation
dt.SetTableLocation Location, &quot;&quot;, &quot;&quot;
.Database.SetDataSource crxReport
'dt.SetLogOnInfo frmLogin.DBServer, frmLogin.dbname, frmLogin.DBSQLId, frmLogin.DBSQLPassword
dt.SetLogOnInfo frmLogin.DBServer, frmLogin.dbname, &quot;gh&quot;, &quot;gh&quot;
'sleep (3)

'dt.SetLogOnInfo frmLogin.DBServer, frmLogin.dbname

Next
End With
'tmrTimer.Index

'tmrTimer.Interval
Next
End If

What it seeams to me is happening is that the sub report logon data is not getting refreshed.

Thanks for any help

Pawel
 
hi
I dont think you can have 2 sub report caal in the vb app

cheers

pgtek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top