Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Unanswered: How to change the path of database through Code for report

    I hvae developed a project for staff attendance with VB and Access using ADO Library
    I used Crystal Report 8 for reporting.
    When I was creating reports the database path was F:\Attdb\AttSys.Mdb
    I have run that project in VB so many times and it run well.
    I developed SETUP for that project and install that setup on the other PC where F:\AttSys\Attdb.Mdb
    was not available
    After installing that project it run well but whrn try to open thew reports they give the error
    which shows that database path is not correct. Its trying to get F:\AttSys\Attdb.Mdb which is not available.
    How to solve this problem.
    Please help me

    I m using the following code to show report

    Dim Report As New CrDailyRep
    Dim Db As New ADODB.Connection
    Dim Rs As New ADODB.Recordset

    Private Sub Form_Load()

    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    Screen.MousePointer = vbDefault

    Call ViewRep

    End Sub

    Private Sub Form_Resize()
    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth

    End Sub

    Public Sub ViewRep()

    Set Db = New ADODB.Connection
    Db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\" & "AttDb.mdb;Persist Security Info=False"

    Set Rs = New ADODB.Recordset
    With Rs
    .Open "Select * from Tbl_Emp_Att", Db, adOpenDynamic, adLockOptimistic
    On Error Resume Next

    Report.Text2.SetText "REPORT OF " & FrmDaily.TxtDate.Text

    StrSel = "{Tbl_Emp_Att.Att_Date} in Date(" & _
    Format(FrmDaily.TxtDate, "yyyy,m,d") & ") to Date(" & _
    Format(FrmDaily.TxtDate, "yyyy,m,d") & ")"

    Report.Database.SetDataSource Rs
    Report.RecordSelectionFormula = StrSel

    CRViewer1.ReportSource = Report
    CRViewer1.EnableRefreshButton = True


    End With
    End Sub

  2. #2
    Join Date
    Mar 2006
    In newer versions of crystal there is a property in the Report object called Filename. Put the path of the report like so

    Report.FileName = "F:\....rpt"

    Hope this works in Crystal 8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts