Working from Main form to Sub-form

G

Guest

I am trying to do the following with a button located on the main form:
1 - Transfer control to the sub-form
2 - Allow additional records to be added to the sub-form

The main and sub-forms both have the following parameters set "on open" :
Allow Edit - No
Allow Deletions - No
Allow Additions - No
I need to change the Sub-form "Allow Additions" to Yes when I click on the
button located on the main form.

So far my code is:
DoCmd.GoToControl "Sub-form" (This Works))
Me!Details.Enabled = True (This Appears to Work -
No errors)
Me.AllowAdditions = True (Can't get past this
point ! )

Thank You in advance for any assistance!
 
S

Steve

What is "Details"?

This line:
Me.AllowAdditions = True
Should be:
Me!nameOfSubformControlOnMainForm.Form.AllowAdditions

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Steve,

Tried that change - still doesn't work. Error message "Object doesn't
support this property or method' is what is returned.

"Details" is the name of the subform. The full code I use is:
Private Sub Update_Click()
On Error GoTo Update_Click_Err

DoCmd.GoToControl "Details"
Me!Details.AllowAdditions

Update_Click_Exit:
Exit Sub

Update_Click_Err:
MsgBox Error$
Resume Update_Click_Exit

End Sub

What the forms do is track tasks that need to be completed. The main form
has the basic information, and the sub-form contains details that happen over
time. Actually, it is a form with 'Default View' set to 'continuious forms'.

Thanks for the attempt.

Harry J.
'The more I learn, the less I know'
 
S

Steve

Your problem is in the line DoCmd.GoToControl "Details".

Change these two lines:
DoCmd.GoToControl "Details"
Me!Details.AllowAdditions

To:
Me!NameOfSubfortmControl.SetFocus
Me!Me!NameOfSubfortmControl.Form!MyField.SetFocus
Me!Me!NameOfSubfortmControl.Form.AllowAdditions


PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Steve,

Still getting the same message "Object doesn't support this property or
method". The last two lines you gave started with 'Me!me!' which I changed
to 'Me!' when it didn't work the first time.

It appears as if the hangup is with the 'AllowAdditions'.

Thanks again.

Harry J.
'The more I learn, the less I know'
 
D

Douglas J. Steele

AllowAdditions is a property of the form. You can't simply refer to a
property without doing something with it.

If you're trying to set it to allow additions, you need

Me!NameOfSubfortmControl.Form.AllowAdditions = True

If you're trying to set it to disallow additions, you need

Me!NameOfSubfortmControl.Form.AllowAdditions = False
 
S

Steve

Sorry about "Me!Me"!!

Open your main form in design view. Click on the border that surrounds your
subform (that's the subform control on the main form). Click on properties
and go to the Other tab. What is the name of the subform control?

Now post the code as you have it now.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Steve & Douglas,

Between you two, IT WORKS.
I had to add the '= True" to the end of the 'AllowAdditions' line.

Thank you so much. This has been the holdup for two days, and now we can
move on!

HarryJ
'The more I learn, the less I know'
 

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