How to display a navvigation control content based on selection of another nagivation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcbehnet
    New Member
    • Aug 2014
    • 5

    How to display a navvigation control content based on selection of another nagivation

    I am using a navigation form with top navigation control named as "NavigationCont roTop" and left navigation control named as "NavigationCont roLeft". The subform where the main content is displayed is named as "NavigationSubf orm"

    I had written VBA code for user control to display different content in "NavigationSubf orm" when the user log in.

    Once a user log in, I had placed a code to set the focus to the related tab in the "NavigationCont roTop", the navigation button for the tab is "nvbProduction" :

    me!nvbProductio n.SetFocus

    This works, but does not seems to activate the navigation button.

    I had also placed a code in the VBA to display the correct content in the "NavigationSubf orm" as below:

    Me!NavigationSu bform.SourceObj ect = "Nav_DeptMainPa ge"

    This works too.

    The problem I faced now is How to display the correct content in "NavigationCont roLeft".

    I had set different navigation buttons in the "NavigationCont roLeft" which display different sub menu and a different department is clicked in the "NavigationCont roTop", which works properly. But in VBA code, how am I going to refer to the different content?

    I tried:

    me!NavigationCo ntroLeft.setfoc us
    me!NavigationCo ntroLeft.requer y

    but does not work.

    Any body can advice please?

    Thank you
    Beh Kea Chang
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1290

    #2
    kcbehnet, Be sure to get in the habit of putting your lines of code inside Code tags. With one line it doesn't make much difference but longer samples of code are much more readable like that. Just click the [CODE/] button and put your code between the tags.

    SetFocus merely makes a control the active control, it does not activate it. What you need to do is run the code that runs from the activating event. With a button it's the OnClick event. With a listbox or combobox it's the AfterUpdate event. In this case, I suspect it is the OnClick event. Whatever the name of that event code is, that's the subroutine you want to run. So it should be as swimple as
    Code:
    NavigationControlLeft_Click()
    Give that a try.

    Jim

    Comment

    • kcbehnet
      New Member
      • Aug 2014
      • 5

      #3
      Dear Tim,

      Thank you for your suggestion, but it does not work for my case.

      I am using the auto Navigation form of Access 2010. So there is no event set for the navigation buttons.

      When I select to set up Navigation form with Top horizontal NavigationContr oTop and left vertical NavigationContr oLeft. There seems to be some hidden code by Microsoft the automatically operated. When I click on a Navigation (say nvbProduction), it loads a form into the NavigationSubfo rm and at the same time it make the left NavigationContr oLeft to reflect the sub-menu for the Production department.

      As I am setting up user log in to the system, I used some code in the Form load event to set the related departmental navigation buttons to default (in this case, the nvbProduction button).

      So when the nvbProduction button is default, I open form Nav_DeptMainPag e in the NavigationSubfo rm with the following code:
      Code:
      Me!NavigationSubform.SourceObject = "Nav_DeptMainPage"
      I plan to open the related "navigation buttons group" in the NavigationContr oLeft navigation control by the following code, but I do not how to refer to the related "navigation buttons group" which was automatically setup by Access when I add in extra Navigation buttons in Layoutview.
      Code:
      Me!NavigationControLeft.SourceObject = "navigation buttons group"
      The "navigation buttons group" is unknown to me as it was set up by Access automatically.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Your answer is here:
        + http://bytes.com/topic/access/answer...rm#post3771117

        With more information via
        +http://bytes.com/topic/access/answer...rm#post3771135

        Comment

        • kcbehnet
          New Member
          • Aug 2014
          • 5

          #5
          I had tried the docmd. browseto command. It does not work.

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            When you say, it doesn't work, that is a very nondescript statement. It gives no detail as to what you wanted to happen, what did (or did not) happen, code, form design, errors, etc...

            The docmd.browseto method works just fine in the databases I use it in.
            For example..
            I have a two tiered Navigation Control.
            ACC2010-NavCtrl>TierOne >SubTierToTierO ne

            SO:
            ACC2010-NavCtrl>Items>I temInventory
            This loads a form in the navigationsubfo rm that shows the basic inventory item information such as serial_lot_numb er, partnumber, description, etc.... the Primary Key field is set so that on click event takes the selected record, pulls the primary key and uses it in the "wherecondition " parameter (mind you it's a properly formated SQL where clause string) to "switch tabs"
            ACC2010-NavCtrl>Item>It emHistory
            So with a nice single click, I move from the one line inventory record to the records that log the cradle to grave.
            This form also has event code that upon entering a new item into the inventory, once confirmed, an entry is made into the history log indicating when the item was entered into the database and then browses to the ACC2010-NavCtrl>Item>It emHistory so that additional entries can be made such as when the item was actually received and who received it, etc...

            Or, I have:
            ACC2010-NavCtrl>Facilit y>OpLocations
            This button loads the form in the navigationsubfo rm that has a parent with the operational locations as recordsource with a child subform that pulls the items (same format as ItemInventory)c urrently checked-out to that OpLocation.
            Once again, the the Primary Key field of the childform is set so that on click event takes the selected record, pulls the primary key and uses it in the "wherecondition " parameter (mind you it's a properly formated SQL where clause string) to "switch tabs" to
            ACC2010-NavCtrl>Item>It emHistory

            So it works if the command is used correctly and the forms are designed properly to handle the navigation.

            Comment

            Working...