Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow Additions using VBA

Status
Not open for further replies.

gojohnnygogogogo

Programmer
May 22, 2002
161
GB
gurus, if I click on my form, properties, data tab, I can allow additions here.
I don't want to allow additions all the time, only when one button is pressed, can I set this to Yes then add the record, then set it back to NO via VBA ?

regards,
John
 
No problems.

me.allowadditions=true
...
do your stuff
...
me.allowadditions=false
 
When I try this I get a run-time error '2647'
The expression you entered refers to an object this is closed or doesn't exist.
on debug it refers to:
Me.AllowAdditions = True

( I have allow additions set to No on the form properties )
(ps, this is a sub form, so would I nee dto put subform name instead of Me ?)

just tried putting the subform name like :

Forms!Test1.AllowAdditions = True

and I get this erorr :
run-time error '438'
object doesn't support this property or method
 
I've got this code running off an 'Add Record' button that is on the subform....

On Error GoTo Err_NewRecButton_Click

Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me![CallerID].Value = Forms![CallerID]![CallerID].Value
Me![Notes].SetFocus
Me.AllowAdditions = False

Exit_NewRecButton_Click:

Exit Sub

Err_NewRecButton_Click:

MsgBox Err.Description
Resume Exit_NewRecButton_Click
End Sub

But this runs from the form I am adding the record to. One posibility would be to move the focus to the subform first, then run the code, by having the first command being me!mysubform.setfocus.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top