Run-time error ‘2501’

D

David Cleave

Hi all

I’m getting this one in the middle of a complicated bit of code which
sometimes needs input from the user. The error appears on the DoCmd.Openform
line and says:

Run-time error ‘2501’
The Openform action was cancelled.

Any ways around this one?

Many thanks

David
 
K

Ken Snell [MVP]

It means that the form's opening was cancelled, perhaps by code running in
that form's Open event that cancels that event.

Without knowing more about what your code is and what it's doing, we can't
give much more information as an answer.

Likely you can just trap for that error by putting
On Error Resume Next

just before the DoCmd.OpenForm, and then check for this error after the
DoCmd.OpenForm line:
If Err.Number = 2501 Then
' ignore the error
Else
' tell the user about the error
MsgBox "Error occurred: Error Number " & Err.Number _
" -- " & Err.Description
End If
 
D

David Cleave

Thanks Ken, you're quite right. The form to be opened is normally used in a
different context and had a recordsource that couldn't be opened. I will
program the code to change the recordsource before opening the form.

Cheers

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top