Crystal Report Viewer Connection

JC3

Registered User.
Local time
Today, 01:14
Joined
Jun 13, 2005
Messages
53
Hi

From looking at various posts here and elsewhere I have managed to create a form containing the Crystal Report Viewer Control 9.0 Active X and a command button with the undernoted code.

Option Compare Database
Option Explicit

Public CRReport As CRAXDRT.Report
Public CRApplication As New CRAXDRT.Application
Public ReportLoc As String

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

ReportLoc = "filelocation"
Set CRReport = CRApplication.OpenReport(ReportLoc)
CRReport.ReadRecords
Me!crtest.ReportSource = CRReport
Me!crtest.ViewReport

While Me!crtest.IsBusy
DoEvents
Wend

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Command0_Click

End Sub

This allows me to open the report in the viewer with no problems. But if I try to refresh the data then I get the error,

Logon Failed.
Logon Failed for User 'SA'.

I know that I need to set the connection properties but I don't know how to go about doing this.

Can anyone help me.

Thanks

JC
 
Figured it out.

Just add the code

For Each CRTable In CRReport.Database.Tables
Set CRConnect = CRTable.ConnectionProperties("Password")
CRConnect.Value = "password"
Next

Simple when you manage it.

JC
 

Users who are viewing this thread

Back
Top Bottom