Question Run Time Error 2501: Please Help

gkhouri

New member
Local time
Today, 01:17
Joined
Sep 2, 2009
Messages
1
Hi all,

Im new to this forum, but i need some desperate help.

I was assisting a friend who's PC crashed...(Motherboard). Any way he runs Physiotherapy business and had an access application which keeps record of his clients and other transactions. I plugged the HDD into another PC and retrieved the folder which holds the access DB and any other associated files.

Now to the problem... When he opens the access database all seems to work, however on one of the forms (The most important i might add) he recieves a Run Time Error 2501:The OpenForm Action was canceled.

When i debug it points me to the
DoCmd.openForm "frmPatientRecordsExisting" (Attached Image)

I looked at the code but im no programmer so i really would appreciate some help.
I have attached the code of frmPatientRecordsExisting form

Everything else seems to work fine and i cant get my head around it. I have checked the references and they all seem fine. Again I am not an Access programmer so my knowledge is limited..

I really appreciate any help
 

Attachments

i dont think the bug is in the txt file you gave us. it might be elsewhere. i think someone would have to see it all to figure it out..
 
A couple things -

1. You can't use a sort command in the form's open event because the recordset has not yet loaded. It comes in the On Load event which comes after the Open event.

2. You don't reference the current form by using its full name (it should be okay, but many times it pukes), so you use the keyword ME to designate the current class object that the code is on.

So, something like this:
Forms![frmPatientRecordsExisting]![Surname].SetFocus

Would be referenced like:

Me.Surname.SetFocus

And you don't need the brackets in code where the name does not have spaces. Also, you should normally use the dot operator instead of the bang when referring to controls.
 
you get an error 2501 when a form/report doesnt open - often this occurs after a genuine issue eg in a report, the onnodata event is used to close the report - this produces a 2501 error.

now if a form doesnt open because the uinderlying query fails (eg type mismatch) this is also gives you a 2501 error in response to a docmd.openform - so i would try to open the form directly, and maybe open the underlying query directly to see what is going on
 

Users who are viewing this thread

Back
Top Bottom