Object is locked error

Boozer

Board Regular
Joined
May 20, 2002
Messages
52
I created a form which contains multiple graphs based off data in one of my tables. The only thing different about this form from all the others i created is that it has these embedded graphs created from multiple count queries. When a user opens this form to look at the graphs, everythings fine, but when the user closes the form, they get "The Object is locked, so any changes you make will be discarded when the form is closed." I get this error 18 times(I have 20 graphs on a tab controled layout). I've gone through everything that has a "Locked" property and set it to false, which had no effect. Could someone point me in the right direction to get rid of this error? I dont need to save anything as the data to create the graphs updates real time, I just want to be able to view the graphs and close them without this error. Thanks in advance!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

I can't test any of these suggestions but I would try:
1. In the form open event, put
Code:
application.docmd.setwarnings = False
and in the form close event, put
Code:
application.docmd.setwarnings = True

If that doesn't work, try this in the form close event,
Code:
DoCmd.CancelEvent
docmd.close

If that doesn't work, let us know...

edit:
You might have to play around with what events you attach these actions to.

HTH,
Corticus
corticus@theofficeexperts.com
 
Upvote 0
I tried a couple of different ways using the above code and got the following errors when running:
2501 close action canceled
2800 Object is locked
I created a button on the form that ran this code:
Application.DoCmd.Close acDefault, , acSaveNo
which specifies no save and it closed the way I want it to without all the propmpt boxes popping up. The event causing the errors appears to fire before the Form_Close event. I added all events and put a break on them to try and determine the event giving the error, I think it is either the Form_Deactivate or Form_LostFocus event. Can I edit/change the event that fires when one hits the close window 'x' for this form only? If so I can just throw Application.DoCmd.Close acDefault, , acSaveNo in that area and not have any other events fire when the form is closed.
 
Upvote 0
Can I edit/change the event that fires when one hits the close window 'x' for this form only? If so I can just throw Application.DoCmd.Close acDefault, , acSaveNo in that area and not have any other events fire when the form is closed.
Sure, use the form_close() event. That sounds like a good plan.

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,501
Messages
6,160,175
Members
451,629
Latest member
MNexcelguy19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top