Allow Edits to Subform

Y

Yukon

BACKGROUND:

1) Form (with subform) does not allow edits in order to safeguard data
from unintentional updates.

Form Properties - Allow Edits - No

2) "Edit Record" Command Button created to allow deliberate changes.

Event - On Click
Me.AllowEdits = True

3) After changes are made, "Save Record" Command Button created to set
form back to Condition 1 above

Event - On Click
Me.AllowEdits = False

4) If the "Save Record" Command Button is not used in Condition 3
above, AfterUpdate Event at form level is set to

AllowEdits = False (to force return to Condition 1 above)


PROBLEM:

When editing data in a record, I sometimes want to update fields in
the subform in addition to the main form.
Condition 4 above returns the subform to "No Edits" when switching
from the mainform to the subform (either by tab or mouse click).

THE VBA CODE:

Private Sub Form_AfterUpdate()

Me.AllowEdits = False ' Return the form to its read-only
state.
MsgBox "Record Saved"

End Sub

QUESTION:

How can I code this to allow edits to the subform before access sets
the entire form to "No Edits"?

Thanks.
 
A

Allen Browne

One way around this issue is to set the Locked property of the bound
controls rather than the AllowEdits property of the form. As well as
avoiding the problem with subforms, this approach has the advantage than any
unbound controls on the form can still be edited (e.g. text boxes used for
filtering, or a combo to navigate to a record.)

If that sounds interesting, see:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
Basically it's a copy'n'paste solution, with very little code to write.
 
Y

Yukon

One way around this issue is to set the Locked property of the bound
controls rather than the AllowEdits property of the form. As well as
avoiding the problem with subforms, this approach has the advantage than any
unbound controls on the form can still be edited (e.g. text boxes used for
filtering, or a combo to navigate to a record.)

If that sounds interesting, see:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
Basically it's a copy'n'paste solution, with very little code to write.

Thank you Allen. Your solution worked perfectly!
 

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