Results 1 to 10 of 10
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365

    Subform error

    Code:
     DoCmd.OpenForm "frmIE", acNormal
            With Me.frmPending.Form
                .RecordSource = "tblPending"
    Goes to error no matter what I try.


    frmIE is a popup modal form and frmPending is a datasheet form I dragged onto it.
    What is the correct syntax for the 2nd line please ?

  2. #2
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    Are you sure frmPending is the name of the subform control that is housing frmPending?
    Please click on the ⭐ below if this post helped you.


  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    To know the solution would require that we know the name of the subform control as already suggested. The syntax for drilling down to a control on a subform is
    [Forms]![Main form name]![subform control name].[Form]![control name on subform]

    You don't need the brackets unless an object name contains spaces. If you don't want to drill down to a control, then truncate that which you don't need from the example syntax.
    You might need to put the main form in design view to get the subform control name. Sometimes it is the same name as the subform; especially if you let Access do this for you. Sometimes it is Child0 (or some other number). Figure that out and you should be ok.

    EDIT - whenever Access gives an object a meaningless name I always change it to something meaningful if I'm not just playing around.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    I've never sure about anything but managed to fluke it with this. After a long time!

    DoCmd.OpenForm "frmIE", acNormal
    Forms!frmIE.Caption = "This is the caption"
    With Forms!frmIE!frmPending.Form
    .RecordSource = "tblPending"

  5. #5
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Thanks Micron, I'll print that out. Everytime I need to do this I go round the twist.
    What actually *is* the subform control. Is it the subform itself ?

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    The subform is just a regular form in terms of designing one. The subform control is the container (control) that houses/contains the subform. You can select the container by clicking on the thin border that surrounds the subform in design view and seeing what name is displayed in the property sheet. The control type is also shown there (IIRC near the top left of the property sheet).
    This might prove useful
    http://access.mvps.org/access/forms/frm0031.htm
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    This could have worked fine:
    Code:
    With Form_frmPending.Form
    .Recourdsource = "tblPending"
    Just make sure the form is open, otherwise this will open it for you. Also make sure frmPending isn't being used somewhere else.
    Please click on the ⭐ below if this post helped you.


  8. #8
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    365
    Think I got it. Form is the Form and container/control is the Form on it's Parent Form.
    Thanks for the link.. sure it a lot of ways to do things.
    Edgar, that worked too, I've changed to it.
    Thanks for the replies.

  9. #9
    Join Date
    Apr 2017
    Posts
    1,680
    Subform is really not a form object, it is a container object (more like tab control), which has a form object as source.

    Open your main form in design view, and click on subform there ONCE! Look at properties - they are for subform control.
    Now click on same subform 2nd time (or double-click at start)! Look at properties again - they are for form contained in subform, and the set of available properties is entirely different from ones displayed for subform.

    I always rename the subform control after creating it. When the form contained in it has name fSomeName, then I rename the subform as sfSomeName

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Subform is really not a form object,
    I prefer to distinguish between the control and the form that it contains by calling one the subform control and the other the subform. True, "subform" is the official name of the control, but then Access isn't perfect is it?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculation Error in SubForm
    By adaoluz in forum Forms
    Replies: 1
    Last Post: 12-10-2018, 02:28 PM
  2. #Name? error when loading a subform
    By stardust1979 in forum Forms
    Replies: 2
    Last Post: 12-21-2014, 08:59 PM
  3. #NAME? error in subform
    By ringram in forum Forms
    Replies: 6
    Last Post: 11-03-2014, 05:03 PM
  4. Replies: 2
    Last Post: 02-12-2013, 11:23 AM
  5. Error with my subform
    By gcommservices in forum Forms
    Replies: 1
    Last Post: 12-29-2011, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums