I've been having troubles with access. The database is stored on the network drive and is accessed by multiple users.
One user has been having troubles just recently in using a search form I created on the database (his screenshot with the error is attached). Over the last month, when he tries to use the search form, he will occasionly get this error message. When you click the Search button, the form is supposed to pull up a report that is based on a query that has its criteria from the form (hope that makes sense). But he (and as far as I know, only he) has been having this problem.
Does anyone know what may be causing this? Has anyone seen this problem before? And, more importantly, does anyone know how to fix it? Thanks in advance to anyone who can help.
As indicated in your screenshot, the OpenReport action was canceled.
Run Time error 2501 most often occurs when something is Canceled. For example, if a report is sent to the printer using the OutputReport action and the user hits cancel while it is spooling, it will return error 2501, which you can trap.
Also, if the OpenForm method is called and something causes the form to cancel opening (either Cancel was set to True during open, or an unhandled error occurs, triggering Cancel = True) then error 2501 is triggered.
There are other ways to get 2501, almost all of them involve canceling an operation.
I suggest you place an error trap in the procedure that opens the report. If Err.Number = 2501, then the user hits cancel. If the Err.number is anything else, post a messagebox with Err.Number and Err.Description
I have the same problem nckdryr but this is an Access issue that I, and numerous other users/developers (do a google) are also experiencing.
Its not a coding problem because as you can see it works fine on some PCs, just individual ones..
The only work around I've discovered is by changing the default printer of the PC in question to something else - the report will then appear fine on screen. However... you won't be able to print it out!! I can only presume there must be a config issue - maybe a service pack will fix it.
Its ironic that I'm developing the Access db, I have these 2051 problems, yet the users I'm supporting don't !!
I had this same problem, and I found the only way to solve it was to change the default printer. However, then I removed the printer and added it back as the default, the problem went away. Hope this helps someone.
As mentioned by the above poster, this error can be triggered by weirdness between your machine and your default printer.
A quick test to see if the printer is issuing the cancel command is to just swap your default printer preference to the microsoft image writer printer (or another working printer) and then retry the open report command.
For some reason, within access when a report document is opened for viewing, some hook is sent to the default printer. If there's any bad mojo going on there, the printer will send a cancel request to the database, triggering the 2501 error.
Delete your default printer and add the printer again and the problem should resolve itself.
I've seen this error in Access 2007 as well and I found this:
MsgBox "There was nothing to report in " & CodeContextObject.Name, vbOKOnly, "Report Printing"
On Error GoTo Error_NoData_Reports:
If Err.Number <> 2501 Then
MsgBox Err.Number & ": " & Err.Description