Can I turn "Allow Deletions" on and off with code?

David Ball

Registered User.
Local time
Tomorrow, 02:05
Joined
Aug 9, 2010
Messages
230
Hi,

I have a combo box and have set "Allow Deletions" to "No" in Properties.

I want to be able to allow the user to delete records if they press an "Allow Edit" button.

Can I use VBA code from a button's On Click event to change the "Allow Deletions" setting to "Yes"?

I tried the code shown below but it does not work ( also tried "True" instead of "Yes").

Forms![formEquipmentType]![subformTestEquip/FIC Subform].Allow Deletions = Yes

I get a message "Object does not support this property or method".

Thanks

Dave B
 
You need to refer to the Source Object of the subformcontrol using the .Form property.

Code:
Forms![formEquipmentType]![subformTestEquip/FIC Subform].Form.AllowDeletions = True

The subformcontrol name must be
[subformTestEquip/FIC Subform]

BTW Using the slash or other special characters in an object name is not a good practice.
 
Last edited:
There's no space between Allow and Deletions. You may also need to tweak the form reference:

http://www.mvps.org/access/forms/frm0031.htm

I'd use True & False, though Yes and No might also work.
 
Thanks. I tried the code:

Forms![formEquipmentType]![subformTestEquip/FIC Subform].Form.Allow Deletions = True

but I get a message "Application defined or object defined error".

I appreciate the tip on not using a slash in the object name, also.

Dave B
 
Thanks Paul.
I just pasted the OP's line without looking. Fixed it now.

Their space may actually be an artifact of the automatic insertion of a space by the forum to stop the line getting too long.
Just another reason why it is always better to put code in a code box.
 
Thanks a lot. After playing around a bit I got it working using:

Me![subformTestEquip/FIC Subform].Form.AllowDeletions = True

Thanks guys

Dave B
 

Users who are viewing this thread

Back
Top Bottom