• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Runtime error 2501

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?
0
syldania
Asked:
syldania
  • 2
1 Solution
 
Alan WarrenCommented:
Source: Visual Basic Help

NoData Event — Event Procedures Example

The following example shows how to cancel printing a report when it has no data. A message box notifying the user that the printing has been canceled is also displayed.

To try this example, add the following event procedure to a report. Try running the report when it contains no data.

Private Sub Report_NoData(Cancel As Integer)
    MsgBox "The report has no data." _
        & chr(13) & "Printing is canceled. " _
        & chr(13) & "Check the data source for the " _
        & chr(13) & "report. Make sure you entered " _
        & chr(13) & "the correct criteria (for " _
        & chr(13) & "example, a valid range of " _
        & chr(13) & "dates),." vbOKOnly + vbInformation
    Cancel = True
End Sub

Alan
0
 
gwgawCommented:
You are getting the parameter box because Specialist is not a field in the table or query the report is based on or it is a parameter in a query the report is based on. Redesign your table and/or query so that Specialist is included as a field and not a parameter.

Use Alan's suggestion on the NoData event and add the following line

On Error Resume Next

before this line

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

in your cmdPreviewSpecialist_Click sub.

gaw
0
 
Alan WarrenCommented:
Thanks syldania

Regards Alan

Applications Development
Cash Australia (Int) Pty Ltd
http://www.cashoz.com
MailTo: alan@cashoz.com

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now