Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Working from Main form to Sub-form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HMJessen - 13 Jun 2007 14:49 GMT
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!
Steve - 13 Jun 2007 15:54 GMT
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
resource@pcdatasheet.com

>I am trying to do the following with a button located on the main form:
>   1 - Transfer control to the sub-form
[quoted text clipped - 16 lines]
>
> Thank You in advance for any assistance!
HMJessen - 13 Jun 2007 17:50 GMT
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'

> What is "Details"?
>
[quoted text clipped - 28 lines]
> >
> > Thank You in advance for any assistance!
Steve - 13 Jun 2007 18:33 GMT
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
resource@pcdatasheet.com

> Steve,
>
[quoted text clipped - 63 lines]
>> >
>> > Thank You in advance for any assistance!
HMJessen - 13 Jun 2007 18:55 GMT
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'

> Your problem is in the line DoCmd.GoToControl "Details".
>
[quoted text clipped - 79 lines]
> >> >
> >> > Thank You in advance for any assistance!
Douglas J. Steele - 13 Jun 2007 19:03 GMT
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

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Steve,
>
[quoted text clipped - 98 lines]
>> >> >
>> >> > Thank You in advance for any assistance!
Steve - 13 Jun 2007 19:04 GMT
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
resource@pcdatasheet.com

> Steve,
>
[quoted text clipped - 98 lines]
>> >> >
>> >> > Thank You in advance for any assistance!
HMJessen - 13 Jun 2007 19:31 GMT
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'

> Sorry about "Me!Me"!!
>
[quoted text clipped - 111 lines]
> >> >> >
> >> >> > Thank You in advance for any assistance!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.