Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write Code for Crystal Report Logon server Access Database

Status
Not open for further replies.

Mirak

Programmer
Aug 1, 2001
28
0
0
Hi,

I have an application that connects to an access 97 database. The database is password protected, therefore I need to code the connection in my application. I have managed to write the code for vb to connect to the database. However I am having a problem with the reports because they are designed in crystal. Whenever I try to run the report, I get an error that says "File could not be open: Name of Query" at file location: Name of Query. I assume its because of the password protection. Is there a way to code the logon server properties in the code.
Here is the code that I use to open the report.

Private Sub cmdRun_Click()
Dim StrReport As String
Dim StrFormula As String
Const conquote = """"
Dim StrCaption As String
Dim year As String, year1 As String


Dim strSQL As String


On Error Resume Next

StrReport = strPath & "\rptAnnualFeesSummary.rpt"
StrCaption = "OSI - Annual Fees Report"

If Me.cboYear.Text = "" Or Me.cboYear.Text = "" Then
MsgBox "Please select a year range for the report", vbOKOnly + vbCritical
Exit Sub
End If

If Len(Me.cboYear.Text) > 0 And Len(Me.cboYear1.Text) > 0 Then

year = Me.cboYear.Text
year1 = Me.cboYear1.Text
StrFormula = "{qryAnnualFees.Year} = " & "'" & year & "'" & " to " & "'" & year1 & "'"

End If
Me.Text1.Text = StrFormula



With crptCrystal
'Set Source, Report name and Destination
.DataFiles(0) = _
strPath & "\SupervisorOfInsurance97.mdb"
.ReportFileName = StrReport
.Destination = crptToWindow
.LogonServer ????????????????????????
.WindowTitle = StrCaption
.SelectionFormula = StrFormula
.WindowState = crptMaximized
' Print the report
.WindowShowRefreshBtn = True
.WindowShowProgressCtls = True
.PrintReport

End With


Exit Sub
error: MsgBox Err.Description, vbOKOnly

End Sub
How can I code in the logon server parameters???
 
Hi,
i think I finally resolved my problem. Instead of coding the logon server, I just needed to set the parameters for the username and password for the access database. Here is what the code looks like for the crystal object.

With crptCrystal
'Set Source, Report name and Destination
.DataFiles(0) = _
strPath & "\SupervisorOfInsurance97.mdb"
.ReportFileName = StrReport
.Destination = crptToWindow
.username = Chr$(10) & strUserID
.password = Chr$(10) & strPassword
.WindowTitle = StrCaption
.SelectionFormula = StrFormula
.WindowState = crptMaximized
' Print the report
.WindowShowRefreshBtn = True
.WindowShowProgressCtls = True
.PrintReport

End With
In this example I stored the username and password in variables.

Mirak
If God be for us, who can be against us!
 

There you go!
Thanks for responding back and posting your solution!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top