Runtime error 2501

Mike Hughes

Registered User.
Local time
Today, 13:34
Joined
Mar 23, 2002
Messages
493
I HAVE A FORM WHERE THE USER SELECTS A REPORT(DISABILITY APPLICATIONS) BY CLICKING ONE OF MANY RADIO BUTTONS . THE USER THEN SELECTS A SPECIALIST (STEPHANIE) FROM SEVERAL NAMES IN A COMBO BOX AND THEN CLICKS ON A PREVIEW BUTTON, TO PREVIEW THE REPORT.
WHEN I CLICK THE PREVIEW BUTTON A PARAMETER VALUE BOX COMES UP ASKING ME TO ENTER THE NAME OF THE SPECIALIST. IF I ENTER A NAME THEN I’M TAKEN TO THE REPORT WITH NO DATA, BECAUSE THAT SPECIALIST HAS NO CASES IN THAT REPORT.
BUT IF I CLICK CANCEL ON THE PARAMETER VALUE BOX
I ‘M GETTING A RUNTIME ERROR 2501 AND I’M ASKED IF I WANT TO DEBUG. I CLICK DEBUG AND I’M TAKEN TO THIS CODE WITH THE LINE,
DoCmd.OpenReport strReport, acViewPreview, , "[Specialist]='" & Me!cmbSpecialist & "'"
HIGHLIGHTED IN YELLOW. WHEN I MOUSE OVER THE LINE I GET THIS:
strReport=”DISABILITY APPLICATIONS” acViewPreview=2 Me!cmbSpecialist “STEPHANIE”

SHOULD I CHANGE THIS LINE TO WHAT THIS IS TELLING ME AND HOW WILL THAT AFFECT THE OTHER REPORTS AND SPECIALISTS WHEN I TRY TO PREVIEW OR PRINT THEM?


Private Sub cmdPreviewSpecialist_Click()
'THIS IS TO PREVIEW SPECIALIST SELECT REPORTS

Dim strReport As String
StrLinkCriteria = "Specialist = '" & cmbSpecialist & "'"


Select Case fraReports
Case 1:
strReport = "APPROVALS"
Case 2:
strReport = "APPROVED ADDITIONAL CONDITIONS"
Case 3:
strReport = "APPROVE/DENY COMBO"
Case 4:
strReport = "APPROVE/DENY OPTION 1"
Case 5:
strReport = "DENIALS"
Case 6:
strReport = "DENIALS WITH OPTION 1"
Case 7:
strReport = "REVIEW CONTINUANCES"
Case 8:
strReport = "TIME AGING"
Case 9:
strReport = "DISABILITY APPLICATIONS"
Case 10:
strReport = "REVIEW DISCONTINUANCES"
Case 11:
strReport = "SIX MONTHS OR OLDER"
Case 12:
strReport = "SPECIALIST MONTHLY REPORTS"
End Select

DoCmd.OpenReport strReport, acViewPreview, , "[Specialist]='" & Me!cmbSpecialist & "'"
End Sub

Can anyone help?
 
Limit the combo box selections to specialists who have cases or do a DLookup first to the appropriate table to see if the specialist has any cases. If yes, run report. If not, alert the user and exit the sub. The first is more user friendly.

Second, instead of the radio buttons in a frame. Set up a report table containing two fields, ReportName and ReportTitle. Create a query against the table with the records sorted ascending on title. Use this query as the row source of a list box. Set the bound column to zero, but make only the second column (the report's title) visible to the user. On the double-click event of the list box, run the report that is indicated by the value of the list box, which of course will be the name of the report selected by the user. You can add the criteria selected by the user to the DoCmd.OpenReport command.

This is a very flexible method because new reports need only to added to the report table.
 

Users who are viewing this thread

Back
Top Bottom