Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[color green]'General Declarations[/color]
Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Dim crxTables As CRAXDRT.DatabaseTables
Dim crxTable As CRAXDRT.DatabaseTable
Dim crxSubreportObject As CRAXDRT.SubreportObject
Dim crxSubReport As CRAXDRT.Report
Dim crxSections As CRAXDRT.Sections
Dim crxSection As CRAXDRT.Section
Private Sub Form_Load()
[color green]'Variable declarations[/color]
Dim strServerOrDSNName As String
Dim strDBNameOrPath As String
Dim strUserID As String
Dim strPassword As String
strServerOrDSNName = "MyServer"
strDBNameOrPath = "NewDB"
strUserID = "user"
strPassword = "pwd"
[color green]'Open the report[/color]
Set crxRpt = crxApp.OpenReport("C:\Employee_Profile.rpt")
[color green]'Set the connection for the report.
'SetLogOnInfo is a deprecated method in CR 9, _
but still works.
'The suggested method for CR9 is to use _
the ConnectionProperty object.[/color]
crxRpt.Database.Tables(1).SetLogOnInfo strServerOrDSNName, _
strDBNameOrPath, strUserID, strPassword
[color green]'This removes the schema from the Database Table's Location property.[/color]
Set crxTables = crxRpt.Database.Tables
For Each crxTable In crxTables
With crxTable
.Location = .Name
End With
Next
[color green]'Loop through the Report's Sections to find any subreports, _
and change them as well[/color]
Set crxSections = crxRpt.Sections
For i = 1 To crxSections.Count
Set crxSection = crxSections(i)
For j = 1 To crxSection.ReportObjects.Count
If crxSection.ReportObjects(j).Kind = crSubreportObject Then
Set crxSubreportObject = crxSection.ReportObjects(j)
[color green]'Open the subreport, and treat like any other report[/color]
Set crxSubReport = crxSubreportObject.OpenSubreport
Set crxTables = crxSubReport.Database.Tables
For Each crxTable In crxTables
With crxTable
.SetLogOnInfo strServerOrDSNName, _
strDBNameOrPath, strUserID, strPassword
.Location = .Name
End With
Next
End If
Next j
Next i
[color green]'View the report[/color]
Viewer.ReportSource = crxRpt
Viewer.ViewReport
End Sub
[color green]'This removes the schema from the Database Table's Location property.
'In CR XI (and maybe in CR 9 and up), when reading the Location property,
' only the table/procedure name is returned, without the schema.
'By setting the Location equal to itself, we are potentially overwriting
' any schema saved with the report, which is a good thing.[/color]
Set crxTables = crxRpt.Database.Tables
For Each crxTable In crxTables
With crxTable
.Location = .Location
End With
Next