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

Lock a Sub-Form from a Form control

P: n/a
** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Private Sub Locked_AfterUpdate()
[Forms]![SubForm1]!form.AllowEdits = Not(locked)
End Sub
ja*******@hotmail.com (Jason G) wrote in message news:<ae**************************@posting.google. com>...
** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.

Nov 12 '05 #2

P: n/a
When refering to properties you need to use a . and not a !
Also, make the language of the checkbox option correspond to the property it
is affecting. In this case for instance, make the checkbox mean "Form is
UnLocked" and not "Form is Locked". this way you can simply use in the
checkboxes AfterUpdate event...

Me!subformcontrol.Form.AllowEdits = Me!checkbox.

If it is checked (True) then this sets the property to true and allows
editing, otherwise it will prevent them.

Also, use the OnLoad event of the main form to do the inital locking. In the
same manner.
Controls don't have OnLoad Events.

Your code is not compiling for a number of reasons.I
It is looking for a Fuction or Sub called SetValue, it won't look at
macros.
Second, ![AllowEdits] is a property, not a control, so refering to it in
this manner is not allowed.

Hope this makes sense.
Mike Storr
www.veraccess.com

"Jason G" <ja*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.