|
-
Apr 2nd, 2008, 08:18 AM
#1
Thread Starter
Fanatic Member
Crystal 10 Relative pathnames?
Does anyone know if you can set crystal 10 to do relative pathnames? I have the database set in my report, but the absolute pathname will change on each machine when the program is distributed. Does anyone know if I can set a relative pathname either through code or in crystal. I'd prefer to do it in Crystal if possible. Crystal 10.
-
Apr 2nd, 2008, 11:45 PM
#2
Re: Crystal 10 Relative pathnames?
When you develop a multiuser application, It's a known practice to give to the user an option where to establish or set the relative path to the data and to the reports (if they are externals rpt files).
Where to save this information, could be : windows' registry, .ini file, .txt file or even an .mdb local file.
And then send this information to Crystal Reports every time you execute a report
-
Apr 3rd, 2008, 07:45 AM
#3
Thread Starter
Fanatic Member
Re: Crystal 10 Relative pathnames?
Right, but how do I pass the report location via code?
-
Apr 3rd, 2008, 12:23 PM
#4
Re: Crystal 10 Relative pathnames?
The next is an example to send data path to a CR10 report
The report is using ADO OLE DB (MS Access) as data source, then you have to modify to your requirements
Code:
'Declarations
Global CRAplicacion As New CRAXDRT.Application
Global CRReport As New CRAXDRT.Report
Global CRConProp As CRAXDRT.ConnectionProperty
Global CRTabla As CRAXDRT.DatabaseTable
Global GRpt As String 'Contains the report's name
Global MyFolder As String 'Contains the relative data path
Global MInt2 As Integer
Global GSelFor As String 'Contains the RecordSelectionFormula
'
'
'
Sub PrintReport()
'here define the report to show
Set CRReport = CRAplicacion.OpenReport(MyFolder & "\" & GRpt, 1)
'here change the relative data path to all the tables defined in the rpt
'in this example all the tables are inside the same mdb file
For MInt2 = 1 To CRReport.Database.Tables.Count
Set CRTabla = CRReporte.Database.Tables(MInt2)
Set CRConProp = CRTabla.ConnectionProperties("Database Type")
CRConProp.Value = "OLE DB (ADO)"
Set CRConProp = CRTabla.ConnectionProperties("Provider")
CRConProp.Value = "Microsoft.Jet.OLEDB.4.0"
Set CRConProp = CRTabla.ConnectionProperties("Data Source")
CRConProp.Value = MyFolder & "\MyDataFile.mdb"
Set CRConProp = CRTabla.ConnectionProperties("User Id")
CRConProp.Value = "Admin"
Set CRConProp = CRTabla.ConnectionProperties("Database Type")
CRConProp.Value = "Access"
Set CRConProp = CRTabla.ConnectionProperties("Locale Identifier")
CRConProp.Value = "1033"
Set CRConProp = CRTabla.ConnectionProperties("OLE DB Services")
CRConProp.Value = "-6"
Next MInt2
'Modify existing rpt Formulas
For MInt2 = 1 To CRReport.FormulaFields.Count
Select Case CRReport.FormulaFields(MInt2).Name
Case "{@a}"
CRReport.FormulaFields(MInt2).Text = "Trim(" & Chr(39) & GTitle & Chr(39) & ")"
Case "{@b}"
CRReport.FormulaFields(MInt2).Text = "Trim(" & Chr(39) & GTitleA & Chr(39) & ")"
Case "{@c}"
CRReport.FormulaFields(MInt2).Text = "Trim(" & Chr(39) & GTitleB & Chr(39) & ")"
End Select
Next MInt2
'Modify record selection criteria
If Trim(GSelFor) <> "" Then
CRReport.RecordSelectionFormula = GSelFor
End If
'frmReport is the form that contains the CR10Viewer
frmReport.Show vbModal
'Release resources
Set CRTabla = Nothing
Set CRConProp = Nothing
Set CRReport = Nothing
Set CRAplicacion = Nothing
And in the frmReport.Form_Load
Code:
CRViewer1.ReportSource = CRReport
CRViewer1.Zoom 1
CRViewer1.ViewReport
Last edited by jggtz; Apr 3rd, 2008 at 12:30 PM.
-
Apr 4th, 2008, 06:53 AM
#5
Thread Starter
Fanatic Member
Re: Crystal 10 Relative pathnames?
I tried your code. I only really had to use one line from it, as the report already has the connection information entered. One problem though: in the connection properties collection, the data source property that you specified doesn't exist. It's database name.
-
Apr 5th, 2008, 01:56 AM
#6
Re: Crystal 10 Relative pathnames?
That's because this example use ADO OLE DB (MS Access) as data source.
ConnectionProperties depend on the report's data source
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|