Results 1 to 6 of 6
  1. #1
    hansendl is offline Advanced Hobbyist
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    38

    A2010 Navigation Forms: "Selecting" a NavigationButton Control Through Code

    Hi all,
    I'm not sure if this is possible, but I need to be able to "select" or "press" a NavigationButton control through code, i.e., replicating all actions that would take place if I were to physically click the button with a mouse. I can get the NavigationSubform control to properly display the correct form through code, but I can't seem to get the appropriate NavigationButton to display as "pressed" (that is, to display the formatting specified in the PressedColor and PressedForeColor properties of the NavigationButton control).



    I read Albert Kallal's solution to this problem here (https://groups.google.com/d/msg/comp...U/irzxAWKvPQsJ), which would work fine if my NavigationButton controls each contained a hard-coded form name in the NavigationTargetName property, but I am creating and loading my subforms on the fly via code that is executed through the OnClick event of each NavigationButton control, so the NavigationTargetName of each button is, by necessity, blank.

    When actually clicking the NavigationButton control, the code behind the button loads the correct form in the NavigationSubform control and Access changes the formatting of the pressed button to indicate the "pressed" state; but when I attempt to replicate these actions through code, by calling the NavigationButton_Click() procedure, I can only get the right subform to display. I can't seem to get Access to recognize the button as "pressed". Instead, the button that was previously "pressed" remains in that state, creating a discrepancy between the visually "pressed" button and the form that is actually loaded in the subform control.

    Any ideas? I've tried using the SetFocus method on the NavigationButton; I've tried SetFocus followed by SendKeys "Enter"; I've looked at the NavigationControl object that houses the NavigationButton controls to see if there was perhaps a way to set a particular NavigationButton control as "Selected"--i.e., something like NavigationControl0.Controls("NavigationButton1").S elected = True--but I couldn't find any documentation that such a property exists (though it must, since Access seems to "know" which control is pressed/selected at any given time). I've also scoured the MSDN library and Access forums for a solution, but can't find anything that works. I don't really want to get into manually setting colors/formatting in code if I can avoid it.

    Thanks!
    Dean

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Misread your post!
    Last edited by burrina; 09-04-2014 at 11:33 PM. Reason: Oops

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I don't use navigation buttons, they take up too much real estate and are too limiting. Is their some reason why you need them?

  4. #4
    hansendl is offline Advanced Hobbyist
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    38
    It's a design choice. It makes for a clean, attractive, and intuitive UI in my opinion, and until now, I haven't found them to be too limiting. The question wasn't really about design choice, however, it was about whether there is a way to programmatically "select" a NavigationButton through code.

    That said, your post got me wondering whether I might be able to replicate the look and feel of the NavigationButton controls by using ToggleButton controls in an OptionGroup instead. I'll have to investigate that idea a little further if no one is able to offer a solution to the original question...

    Thanks,
    Dean

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Command Buttons can be made to look and act just like navigation buttons and give you way more control over your app.

    Good Luck With Your Project!

  6. #6
    hansendl is offline Advanced Hobbyist
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    38
    Just to update, replacing the NavigationControl and NavigationButton controls with an OptionGroup and ToggleButton controls works perfectly.

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

Similar Threads

  1. Replies: 8
    Last Post: 07-15-2014, 05:56 PM
  2. Replies: 4
    Last Post: 07-12-2014, 02:02 PM
  3. Replies: 3
    Last Post: 04-29-2014, 04:49 PM
  4. Replies: 5
    Last Post: 06-25-2012, 02:06 PM
  5. Replies: 0
    Last Post: 01-11-2012, 12:34 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