?
Solved

Runtime error  2501

Posted on 2003-03-12
3
Medium Priority
?
202 Views
Last Modified: 2008-02-01
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
Comment
Question by:syldania
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Alan Warren earned 750 total points
ID: 8124825
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
 
LVL 5

Expert Comment

by:gwgaw
ID: 8128449
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
 
LVL 26

Expert Comment

by:Alan Warren
ID: 8149272
Thanks syldania

Regards Alan

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

0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question