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???
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???