|
-
May 15th, 2003, 08:14 AM
#1
Thread Starter
Banned
Bruce, Techy...its that darn crystal ? again...
Finally got around to writing some code to view my crystal reports..
All is working well EXCEPT when I specify criteria on my form. Meaning I have a form with 4 combo boxes at the top. Users can select a customer followed by a site, followed by a commission, etc. But whenever I specify any criteria I get the following error when I try to open the report:
Login Failed For User SA
blah blah blah....
....
My code is as follows:
VB Code:
Private Sub Form_Load()
On Error GoTo Err_Handler
Dim strReportPath As String
Select Case (frmReports.SSTab1.Tab)
'project
Case 0:
If frmReports.optRptEnc3.Value = True Then
SetRptName ("rptEnclosure3.rpt")
End If
'mgmt
Case 1:
'misc
Case 2:
'admin
Case 3:
End Select
strReportPath = App.Path & "\Reports\"
Set objCrystalApp = New CRAXDRT.Application
Set objReport = objCrystalApp.OpenReport(strReportPath & GetRptName, 0)
'now check for criteria
If frmReports.cboRptQuoteNumbers.Text = "" Then
'no quote
Else
objReport.RecordSelectionFormula = "{Proposals.ProposalID} = " & frmReports.cboRptQuoteNumbers.ItemData(frmReports.cboRptQuoteNumbers.ListIndex)
GoTo LabelViewReport
End If
If frmReports.cboRptCustomers.Text = "" Then
'no customer AND no quote...that means
'NO criteria has been selected..so we simply view
'the report
GoTo LabelViewReport
Else
objReport.RecordSelectionFormula = "{Proposals.CustomerID} = " & frmReports.cboRptCustomers.ItemData(frmReports.cboRptCustomers.ListIndex)
End If
If frmReports.cboRptSites.Text = "" Then
'no customer AND no quote...that means
'NO criteria has been selected..so we simply view
'the report
GoTo LabelViewReport
Else
objReport.RecordSelectionFormula = "And {Proposals.SiteID} = " & frmReports.cboRptSites.ItemData(frmReports.cboRptSites.ListIndex)
End If
If frmReports.cboRptComms.Text = "" Then
'no customer AND no quote...that means
'NO criteria has been selected..so we simply view
'the report
GoTo LabelViewReport
Else
objReport.RecordSelectionFormula = "And {Proposals.CommissionID} = " & frmReports.cboRptComms.ItemData(frmReports.cboRptComms.ListIndex)
End If
LabelViewReport:
frmCRViewer.CRViewer91.ReportSource = objReport
frmCRViewer.CRViewer91.ViewReport
Done:
Set objReport = Nothing
Set objCrystalApp = Nothing
Exit Sub
Err_Handler:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Done
End Sub
First I check which tab the user is on to determin the report. For now I only have 1 report. Then I set the report name. Then I finally check for criteria and then open the report. It always works with no criteria but right when I have criteria it fails.
Jon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|