Open Form Allowedits

Andy74

Registered User.
Local time
Today, 19:56
Joined
May 17, 2014
Messages
126
Hello,

I have a form with a subform in datasheet view. The form (frmMainForm) is originally saved with the form property "Allowedits" set a as false. If I open the form from the navigation panel then the subform is not editable, as expected. If I open the form via VBA with the docmd.openform instruction and then set the form.allowedits property to True programmatically then the subform still is not editable, as it is locked, while all other controls are editable. Can anybody explain this? I would like to avoid this in some way, i.e. keep the form saved with Allowedits false and then make it editable just changing that property.

Andy
 
the form data and controls are 2 different things.
tho you should not be allowed to set a new control value if the form is locked. (which doesn't lock the control)
you can scroll thru the values on a combo ,but not pick one.
 
AllowEdits is propagated to the controls (inc. subform) on design view and not on runtime.
if you need to toggle this property at runtime, you add a Public Sub/Function in your frmMainForm:
Code:
Public Function udfAllowEdits(bolAllow As Boolean)
Dim ctl As Control

For Each ctl In Me.Controls
    If TypeOf ctl Is SubForm Then
        ctl.Form.AllowEdits = bolAllow
    End If
Next
Me.AllowEdits = bolAllow
End Function

use DoCmd.OpenForm as usual, then change the AllowEdits using:
Call Forms!frmMainForm.udfAllowEdits(True) 'to allow edits to form control including subform.
 
AllowEdits is propagated to the controls (inc. subform) on design view and not on runtime.
if you need to toggle this property at runtime, you add a Public Sub/Function in your frmMainForm:
Code:
Public Function udfAllowEdits(bolAllow As Boolean)
Dim ctl As Control

For Each ctl In Me.Controls
    If TypeOf ctl Is SubForm Then
        ctl.Form.AllowEdits = bolAllow
    End If
Next
Me.AllowEdits = bolAllow
End Function

use DoCmd.OpenForm as usual, then change the AllowEdits using:
Call Forms!frmMainForm.udfAllowEdits(True) 'to allow edits to form control including subform.
Thanks ArnelGP, this solved the issue!
 

Users who are viewing this thread

Back
Top Bottom