AllowAdditions = False

G

Guest

Hello,
I have MainForm, SubForm1 and SubForm2. If the CheckBox on SubForm1 = True,
than I would like the AllowAdditions = False on SubForm2. I have the
following code in the On Current Event of SubForm1


If chkboxName = True Then
Me.Parent![SubForm2].AllowAdditions = False
Else
Me.Parent![SubForm2].AllowAdditions = True
End If

When I first used this code it worked but I recieved an error message when I
opened the form(s) "Object doesn't support this property or method."

After trying to troubleshoot the error, the code doesn't work at all.
Thanks for the help
Captain OhNo
 
K

Ken Snell [MVP]

You need the .Form object of the subform, e.g.,

Me.Parent![SubForm2].Form.AllowAdditions = True
 
G

Guest

You are right Ken.
The .Form was in my original code (thanks to previous assistance in this
discussion group) then I left it out after troubleshooting the error message.
Now it does work again but I still get an error message when I open the
form: "You entered an expression that has an invalid reference to the
property form/report."

I tried different things but have not been successful.

Your assistance is greatly appreciated.
Captain OhNo

Ken Snell said:
You need the .Form object of the subform, e.g.,

Me.Parent![SubForm2].Form.AllowAdditions = True

--

Ken Snell
<MS ACCESS MVP>


Captain OhNo said:
Hello,
I have MainForm, SubForm1 and SubForm2. If the CheckBox on SubForm1 =
True,
than I would like the AllowAdditions = False on SubForm2. I have the
following code in the On Current Event of SubForm1


If chkboxName = True Then
Me.Parent![SubForm2].AllowAdditions = False
Else
Me.Parent![SubForm2].AllowAdditions = True
End If

When I first used this code it worked but I recieved an error message when
I
opened the form(s) "Object doesn't support this property or method."

After trying to troubleshoot the error, the code doesn't work at all.
Thanks for the help
Captain OhNo
 
K

Ken Snell [MVP]

When you open a form that has a subform in it, the subform is actually
"loaded" first, then the main form is "loaded". Thus, if your code is
running in the subform's Source Object form's Current event (which, by the
way, occurs during the loading of the form when the first record is put into
the "current" record for the subform), it won't see the Parent main form,
let alone any other subform in that main form.

What I do in these cases is run such code in the main form's Load event, and
have the main form set the subform's properties.
--

Ken Snell
<MS ACCESS MVP>




Captain OhNo said:
You are right Ken.
The .Form was in my original code (thanks to previous assistance in this
discussion group) then I left it out after troubleshooting the error
message.
Now it does work again but I still get an error message when I open the
form: "You entered an expression that has an invalid reference to the
property form/report."

I tried different things but have not been successful.

Your assistance is greatly appreciated.
Captain OhNo

Ken Snell said:
You need the .Form object of the subform, e.g.,

Me.Parent![SubForm2].Form.AllowAdditions = True

--

Ken Snell
<MS ACCESS MVP>


Captain OhNo said:
Hello,
I have MainForm, SubForm1 and SubForm2. If the CheckBox on SubForm1 =
True,
than I would like the AllowAdditions = False on SubForm2. I have the
following code in the On Current Event of SubForm1


If chkboxName = True Then
Me.Parent![SubForm2].AllowAdditions = False
Else
Me.Parent![SubForm2].AllowAdditions = True
End If

When I first used this code it worked but I recieved an error message
when
I
opened the form(s) "Object doesn't support this property or method."

After trying to troubleshoot the error, the code doesn't work at all.
Thanks for the help
Captain OhNo
 

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