Navigation Control - Subforms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ccocker
    New Member
    • Nov 2013
    • 5

    Navigation Control - Subforms

    Hi guys,

    I have in the past referred to controls on subforms without any issue, however with the new navigation control there does not seem to e a subform to refer to other than NavigationSubFo rm.

    I have tried the following:

    Me![NavigationSubfo rm]![prjCustomer] = Forms![menu]!cmbCustomer
    Me![NavigationSubfo rm]![cCustomer] = Forms![menu]!cmbCustomer

    I have also tried:

    Forms![Menu]![NavigationSubfo rm]![prjCustomer] = Forms![menu]!cmbCustomer
    Forms![Menu]![NavigationSubfo rm]![cCustomer] = Forms![menu]!cmbCustomer


    This only works when the subform has the focus i.e. if I am on the Project Overview Subform then the prjCustomer field is updated with the value in cmbCustomer, but the cCustomer field comes up with an error saying it cannot find the field.

    If I move onto the Contacts form then the cCustomer field updates with the value in cmbCustomer, but the prjCustomer field comes up with an error saying it cannot find the field.

    Essentially I want to have a field on my Navigation Control called cmbCustomer and when I update this I want the value to be written into every Customer field on each of the subforms on the Navigation Control. This is so the user only has to select customer once and all the data entry on the other forms will automatically be updated with the customer name.

    Hope that makes sense - any light someone can shed on this would be appreciated.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    ccocker:

    Hang tight!
    I had one (many explictives) learning to use this control.

    Things to keep in mind:
    - The new navigation pane works much like a late bound tab control. It is NOT however at all like a tab control
    - Each time you click on a new navigationcontr ol button/tab, the associated subform is RELOADED from SCRATCH. The subform on the control that you were on is UNLOADED; thus, anything that you had set on that form is NO LONGER available! You have to use the onclose events, temp and module level variables, and other tricks to preserve and transfer the infromation.
    - There is ONE navigation control container on the parent form. This is where all of the subforms refered to by the navigation button/tabs will load. Therefor, ignore the button name and go from the parent to the navigation control then the subform therein.
    This will sometimes get you the correct reference and helpeed me a few times: How to refer to subforms in control sources There's a trick to this with the navigaton control - while in design view make sure that the correct subform is showing... and this doesn't always work.
    Your basic reference is something like this and assumes that you haven't changed the default navigation container name:
    [Forms]![frmParentform]![frmNavigationsu bform].[form].(somecontrolhe re)

    I'll update here with a better example in a few hours after I get a nap and goto work :)

    ()Also, almost as an aside this is a very handy link to have when working with subforms and was actually of some use while trying to learn the new nav control:
    Refer to Form and Subform properties and controls

    I'm glad this worked out.
    By way of finishing the reference as promised in my first post :)

    So I have a calculated control that requires the value from the subform of the parent form within the navigation control.
    Unless you have subforms within subforms this is more than likely as bad as it gets.

    So We have three forms involved here:
    frm_navigation: This is the switchboard. It has all the pretty buttons along the top and side for user navigation.
    frm_qry_asset_i nventory_logboo k: This is the parent form that is bound to the navigation control button. It's a fairly complex query driving this form; however, as one scrolls or searches within this form for an asset, the subform pulls the historical information.
    sfm_qry_asset_i nventory_logboo k this is the subform frm_qry_asset_i nventory_logboo k that pulls the related records from the history/logbook table for the selected asset in the parent.

    We then have the bound control on the subform that I'm after:
    [history_fk_inve ntory] which is bound to that recordsource field in the sfm_qry_asset_i nventory_logboo k form. I need to pull this value into a control on the parent for a calculation.

    So this is what it looks like in the calculated control (ok only partially this has a very long set of calcs)
    Code:
    =[Forms]![frm_navigation]![NavigationSubform].[Form]![sfm_qry_asset_inventory_logbook]![history_fk_inventory]
    so to break this down by step:

    Code:
    [Forms]!                '<Forms Collection 
                               of the database
    
    [frm_navigation]!       '<The Switchboard form
    
    [NavigationSubform].    '<The default name of the
                               new Acc2010 navigation control
    
    [Form]!                 '<Tells us to look at 
                                 the form property of the
                                 navigation control, 
                                 in this case it 
                                 is the parent form: 
                                 frm_qry_asset_inventory_logbook
    
    [sfm_qry_asset_inventory_logbook]! '< This is the subform of the 
                                 Currently loaded parent form
    
    [history_fk_inventory]  '< and finally the 
                                 control of interest. <
    So that got me to the control on the subform of the parentform loaded into the navigationcontr ol.

    What if we needed to get a control on the currently loaded form in the navigation control (we're still using the three afor mentioned forms here):
    Code:
    [Forms]![frm_navigation]![NavigationSubform].[Form]![Inventory_pk]
    Note I did not use "frm_qry_asset_ inventory_logbo ok"

    In fact, if you clicked on a second button, and it loaded a new form (say frm_example2) with the bound control named "[example_pk]" then the reference to that control would be
    Code:
    [Forms]![frm_navigation]![NavigationSubform].[Form]![example_pk]
    Clear as mud... was for me too.

    Fourtunately however, when working within the loaded form; the "ME." construct holds true as does any of the references internally to the form using "Me." and the normal subform references (for example say:
    in vba:
    sfm_qry_asset_i nventory_logboo k
    wanted to address the recordset for:
    frm_qry_asset_i nventory_logboo k
    (both of which are currently loaded into "NavigationSubf orm"

    then the in vba code within "sfm_qry_asset_ inventory_logbo ok" need only use the construct: Me.Parent.Recor dSource and other constructs as shown in the link provided earlier.

    -
    Moveing data: there is, in the navigation control, the tab (button) that is associated with the form, a property, "Navigation Where Clause"
    I've just started playing with this... taking the inventory forms... I have a tab that loads the inventory form... I already have a tab that has the history details... so I've been working with this property so one could select the item in the inventory pane and go directly to that item in the history side.
    Last edited by zmbd; Mar 26 '14, 06:42 PM. Reason: [z{Merged the two posts to make it easier for others to follow in the future}]

    Comment

    • ccocker
      New Member
      • Nov 2013
      • 5

      #3
      Thank you - very helpful. I get why it was not working now, you forced me to re-think my approach.

      So I essentially just created a public function to get the value from the combobox on the main form (so it is always accessible to me). Then on each subform I just call the function and assign it to the field on the subform I am on using the Me! feature.

      Sometimes approaching something in the opposite way to the way you are trying works :-)

      Originally posted by zmbd
      ccocker:

      Hang tight!
      I had one (many explictives) learning to use this control.

      Things to keep in mind:
      - The new navigation pane works much like a late bound tab control. It is NOT however at all like a tab control
      - Each time you click on a new navigationcontr ol button/tab, the associated subform is RELOADED from SCRATCH. The subform on the control that you were on is UNLOADED; thus, anything that you had set on that form is NO LONGER available! You have to use the onclose events, temp and module level variables, and other tricks to preserve and transfer the infromation.
      - There is ONE navigation control container on the parent form. This is where all of the subforms refered to by the navigation button/tabs will load. Therefor, ignore the button name and go from the parent to the navigation control then the subform therein.
      This will sometimes get you the correct reference and helpeed me a few times: How to refer to subforms in control sources There's a trick to this with the navigaton control - while in design view make sure that the correct subform is showing... and this doesn't always work.
      Your basic reference is something like this and assumes that you haven't changed the default navigation container name:
      [Forms]![frmParentform]![frmNavigationsu bform].[form].(somecontrolhe re)

      I'll update here with a better example in a few hours after I get a nap and goto work :)

      ()Also, almost as an aside this is a very handy link to have when working with subforms and was actually of some use while trying to learn the new nav control:
      Refer to Form and Subform properties and controls

      Comment

      • davidjimm
        New Member
        • Apr 2015
        • 1

        #4
        I actually became a member of this site just to say thank you to zmdb!!
        Finally something that can help me with this navigational crap!

        Thanks!!
        Last edited by zmbd; Apr 15 '15, 02:21 PM. Reason: [z{warm fuzzies}]

        Comment

        • Neo001
          New Member
          • Sep 2015
          • 1

          #5
          @ZMBD I've been searching for this solution for daysss now, and was about to give up! thanks so much for the detailed solution. Wish u health strength and good deeds your way!
          btw, I too created an account just to say thanks, lol
          Last edited by zmbd; Oct 4 '15, 02:37 AM. Reason: [z{Thank you Neo001 - been a very busy few months. My pleasure to lend a helping hand!}]

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32634

            #6
            It's very nice of both of you to take the time and effort to reply as you have. I know ZMBD will be thrilled when he sees this, and so he should be. He deserves it.
            Last edited by zmbd; Oct 4 '15, 02:38 AM. Reason: [z{hello neighbor!}]

            Comment

            • Lamar
              New Member
              • Jan 2019
              • 1

              #7
              Count me in as one creating an account to just say thank you.

              Lamar

              Comment

              Working...