cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to load the report

Former Member
0 Kudos

When I put the following code

Me.CrystalReportViewer1.SelectionFormula = "{tbARTICULOS.COD_FAMI} ='" & (Mid(Me.CmbLab1.Text, 1, 4)) & "'"

Me.CrystalReportViewer1.RefreshReport()

before seeing the report, it displays the following message: Unable to load the report.

To remove: Me.CrystalReportViewer1.RefreshReport()

Do not show me the error, but obviously not refresh the report.

Someone called fix this?

Accepted Solutions (1)

Accepted Solutions (1)

former_member208657
Active Contributor
0 Kudos

Please post more information about your issue. What you've included isn't nearly enough to draw a conclusion.

Former Member
0 Kudos

Ok, a button on my form I have the following code

Private Sub cmdReporte_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReporte.Click

Me.CrystalReportViewer1.Visible = True

Me.CrystalReportViewer1.SelectionFormula = "{INV_MOV2.FECHA_DIG} >=#" & Format(Me.DtpFecha1.Value.Date, "MM/dd/yyyy HH:mm:ss") & "#" & _

" and {INV_MOV2.FECHA_DIG} <=#" & Format(Me.DtpFecha2.Value.Date, "MM/dd/yyyy HH:mm:ss") & "#"

Me.CrystalReportViewer1.RefreshReport()

End Sub

When I click on the button, I get the message "Unable to load the report", but then the report shows, I believe this message is not correct and that is a little upset because sample is 2 times.

If I remove the line

Me.CrystalReportViewer1.RefreshReport()

The message is not displayed, but the report does not update.

My question is, ¿What is causing it to display that message?

former_member208657
Active Contributor
0 Kudos

You still haven't provided all your code. I don't see anywhere that you have set your ReportSource.

My initial suspicion is that your report has saved data and when you force the refresh it needs to go back to the database to retrieve the data. You likely aren't setting any database logon credentials at runtime.

If you are new to Crystal Reports I suggest you look at the sticky post in this forum

Former Member
0 Kudos

I understand friend, look at my code

This is the code on the button that displays the report

Private Sub cmdReporte_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReporte.Click

Me.reportDocument1.RecordSelectionFormula = "{CXC_VEND.COD_VEND}>='" & (Mid(Me.CmbAgte1.Text, 1, 2)) & "'"

Me.reportDocument1.Load("
Glauco\TI Backup\Proyectos\Advanced\AdvancedReports\AdvancedReports\RptClieGral.rpt")

End Sub

In the load on the form I have this code:

Private Sub Frm_RptListaClientes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim reportDocument1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument()

End Sub

When I try to view the report, it displays the message "Unable to load the report", however, after presenting the message of the report shows.

former_member208657
Active Contributor
0 Kudos

You are very likely missing your database logon code like a mentioned before. You can utilize the SetDatabaseLogon() method to do this for you.

reportDocument1.SetDatabaseLogon("username", "yourpassword");

Former Member
0 Kudos

You're setting the formula before loading the report. That won't work.

You're also creating the ReportDocument variable in the Page_Load event. That also won't work - the variable will go out of scope at the end of Page_Load and your other routines will try to work with an uninstantiated object (I'm assuming you also have it declared at the form level since you've got a Me.reportDocument1 object declared).

Start simple. Load the report, set database and parameter information, set the formula text, then view the report. I would recommend putting all the code in Page_Load until you have it working, then move it out to other routines as appropriate. Have a look at the samples, as suggested above, for more information.

Answers (1)

Answers (1)

Former Member
0 Kudos

I found a solution halfway.

I put this code in my form:

Private Sub ConfigureCrystalReports()

CrystalReportViewer1.ReportSource = "
Glauco\Reportes\Ventas 08\Vta - Ventas resumidas x teleoperador.rpt"

Me.CrystalReportViewer1.RefreshReport()

End Sub

Then upload it to the load

Private Sub Frm_RptVtasTeleoperador_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ConfigureCrystalReports()

End Sub

On the button that submits the report, I have this code

Private Sub cmdReporte_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReporte.Click

Me.CrystalReportViewer1.Visible = True

Me.CrystalReportViewer1.SelectionFormula = "{INV_MOV2.FECHA_DIG} =#" & Format(Me.DtpFecha1.Value.Date, "MM/dd/yyyy HH:mm:ss") & "#"

Me.CrystalReportViewer1.RefreshReport()

End Sub

With that, in ways that show only a report, the message "Unable to load the report" disappeared. But if I have more than one report

Is not to create this Sub

Private Sub ConfigureCrystalReports()

CrystalReportViewer1.ReportSource = "
Glauco\Reportes\Ventas 08\Vta - Ventas resumidas x teleoperador.rpt"

Me.CrystalReportViewer1.RefreshReport()

End Sub

So now two reports to me the problem remains

former_member208657
Active Contributor
0 Kudos

Anibal,

It appears to me that you are very new to Crystal Reports and need to study the basic material first. This is why I suggested you look at the sticky post at the beginning of this forum I believe you need to go through all the tutorials and look at the best practices before you ask too many other questions here.