By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

AllowAdditions In Subform

P: n/a
Tom
I have a button on a main form that executes code to write to the subform.
The subform's AllowAdditions property is set to false and in the button's
code the subform's AllowAdditions property is set to True before the code to
write to the subform. The code to set AllowAdditions to True is:
Me!NameOfSubformControl.Form.AllowAdditions = True
When I click the button, I get the error message, Error 2448 You can't
assign a value to this object. If I go to the subform's properties and set
AllowAdditions to True and then click the button om the main form, the code
writes to the subform as desired. Is there something special that has to be
done to programatically set a subform's AllowAdditions to True from a main
form?

Thanks,

Tom
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
jv
The syntax to allow additions seems to be ok. Have you set debugging
break point to see where you are you getting the error on the
allowadditions line or on the code to write the new record?

I usually add new records to a subform by using DoCmd.RunSQL "INSERT
INTO ..." then do a me.refresh on the main form.

Nov 13 '05 #2

P: n/a
ABG
Or, another way if you like your current method is to make a copy of
the subform, and have the button first switch the subform out.

me.thesubform.sourceobject = "theNameOfTheOtherSubform"
then have your code do it's writing for you and then set the source
object back.

JV's suggestion is the more elequent method, though

Nov 13 '05 #3

P: n/a
ABG wrote:
Or, another way if you like your current method is to make a copy of
the subform, and have the button first switch the subform out.

me.thesubform.sourceobject = "theNameOfTheOtherSubform"
then have your code do it's writing for you and then set the source
object back.

JV's suggestion is the more elequent method, though


JV's suggestion is an interesting idea. I have used the subform switch
out in the past because if the subform is editable I couldn't always
edit another 'dynaset'. Does the "INSERT INTO ..." SQL work when the
subform is editable?

Thanks in advance,

James A. Fortune

Nov 13 '05 #4

P: n/a

DoCmd.RunSQL "INSERT INTO..." works independent of the form or subforms
because it inserts it directly into the table, not the form. That is
reason why you need to requery afterward so that the new record would
show up on the form.
Julie

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5

P: n/a
julie vazquez wrote:
DoCmd.RunSQL "INSERT INTO..." works independent of the form or subforms because it inserts it directly into the table, not the form. That is
reason why you need to requery afterward so that the new record would
show up on the form.
Julie

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I apologize for being unclear. Let me rephrase the question. If the
editable subform is bound to a table through its RecordSource, will
Access allow the INSERT to the same table to occur at all? With A97 I
have gotten error messages when using an update query under those
conditions. I should stop being lazy and just try it.
James A. Fortune

Nov 13 '05 #6

P: n/a
Update should work as long as the record is not being locked for
whatever reason. Insert should always work regardless.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.