edit button for main and subform

D

deb

I have an edit button on the main form that sets allowedits to true for the
main form and the subform ...see below code.
I click edit to make a change to the main form and if I need to make changes
to the sub form I need to click edit again.

I have the allowedits set to false in the main form AfterUpdate and OnCurrent.

How can I make the edit button work for both forms until I move to another
record in the main form?

Private Sub btnEdit_Click()
Me.AllowEdits = True
Me!f004PMScore.Form.AllowEdits = True


Thanks in advance
 
A

Allen Browne

Hi Deb

This is one of a few issues with AllowEdits that caused me to give up on it
and set the Locked property of the controls as well. The others include the
fact that even unbound controls become uneditable (e.g. if you have text
boxes in the form header for filtering or navigation), and the fact that the
Detail section of the form goes completely blank when you set AllowAdditions
to No and then filter it such that it has no records (and that triggers
other bugs.)

So take a look at:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

The LockBoundControls() function loops through the controls on your form and
recursively on subforms (nested to any depth), and sets the Locked property
of the bound controls. This has the same effect as setting AllowEdits to No,
but none of the side effects.

The example uses the Click event of a button to toggle the locked property,
but you could call it from Form_AfterUpdate if you want it to automatically
lock again after every entry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top