Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get rid of access error message 2501? 1

Status
Not open for further replies.

jazminecat

Programmer
Jun 2, 2003
289
US
Yes, I"m getting the dreaded "the open report action was cancelled" message - and I've searched the forums, and found the threads addressing it, tried out the code, and still get the error - here's my code:

Code:
Option Compare Database

Private Sub Report_Open(Cancel As Integer)

On Error GoTo ErrHandler

Select Case Forms!RunQuery!Frame15

Case 1 'subrecipients
Me.RecordSource = "qrySubrecipient"
Me.Label22.Caption = "Subrecipients"

Case 2 'contracts
Me.RecordSource = "qryContract"
Me.Label22.Caption = "Contracts"
End Select



exitSub:
Exit Sub

ErrHandler:
   If Err.Number = 2501 Then 'exitSub
    Else
       MsgBox Err.Number & vbCrLf & Err.Description
   End If
   Resume exitSub
End Sub




Private Sub Report_NoData(Cancel As Integer)


MsgBox "No records were found."
Cancel = True
DoCmd.OpenForm "RunQuery"


End Sub

Can anyone tell me why it's not ending the open report function and bailing? It goes back to my form correctly, but of course gives me the error as well. ANy thoughts? Thanks!
 
Try:

ErrHandler:
If Err.Number = 2501 Then
Error.Clear 'clear error and continue exit
Else
MsgBox Err.Number & vbCrLf & Err.Description
End If
Resume exitSub

Let them hate - so long as they fear... Lucius Accius
 
nope - I still get a message box saying "The OpenReport action was cancelled".
It doesn't actually say 2501 - and it doesn't say error - it just says microsoft access at the top of the message box, and the text below, and an ok button.

thanks! hope someone knows the solution here!
 
Do something like this, I put this in the button portion, not the report obviously....

On Error Resume Next
DoCmd.Openreport ("rptMyform")
If Err = 2501 Then Err.Clear
 
I'm glad to have helped out!

I noticed you have a label that changes with the record source. I was just doing something similar today except changing the form's caption (the title on the blue band at top)

me.caption = "Whatever I Want To Call This Form"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top