Maychell Alcorin
Maychell Alcorin

Reputation: 838

Crystal report Load Report Failed in vb.net after copying a report

I have an original 2 reports: offset.rpt and roto.rpt

I need to create a new design(putting new logo and changing colors) for the two reports. I copy offset.rpt and named it offset_temp.rpt, I copy roto.rpt and named it roto_temp.rpt

this is my code:

Public Sub ViewReport()
    Dim i As Integer
    i = Main.dgvColorTolerance.CurrentRow.Index
    Dim filePath As String
    If Main.Process = "ROTO" Then
        filePath = Application.StartupPath + "\roto.rpt"
        If Main.lblcheckuni.Text.Contains("NEW") Then
            filePath = Application.StartupPath + "\roto_temp.rpt"
        End If
    Else
        filePath = Application.StartupPath + "\offset.rpt"
        If Main.lblcheckuni.Text.Contains("NEW") Then
            filePath = Application.StartupPath + "\offset_temp.rpt"
        End If
    End If


    cryRpt.Load(filePath)
    cryRpt.RecordSelectionFormula = " ({command.ID} = " & Main.dgvColorTolerance.Item(Main.dgvColorTolerance.Columns.Count - 1, i).Value & ")"
    cryRpt.SetDatabaseLogon("sa_connection", "******")
    CrystalReportViewer1.ReportSource = cryRpt
    CrystalReportViewer1.RefreshReport()
    CrystalReportViewer1.Zoom(85)

when I run it: Error message "Load Report Failed" when lblcheckuni.text contains "NEW" but if not, it runs fine. I google it and some said maybe file is not exist. but It is exist. Please help. Thank you

Upvotes: 0

Views: 979

Answers (1)

APrough
APrough

Reputation: 2701

To get the Desktop path

Dim desktop as string = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
filePath = desktop & "\color_tolerance\ColorTolerance (Win App)\ColorTolerance\" & reportName

Upvotes: 1

Related Questions