Results 1 to 6 of 6

Thread: Crystal 10 Relative pathnames?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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.

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    Re: Crystal 10 Relative pathnames?

    Right, but how do I pass the report location via code?

  4. #4
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    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.

  6. #6
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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
  •  



Click Here to Expand Forum to Full Width