Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Select a particular tab/subform in A2010 Navigation control with VBA

3,642 views
Skip to first unread message

andrewmrichards

unread,
Oct 21, 2010, 6:36:47 PM10/21/10
to
Hi all,

Maybe I'm being dense, but having designed an interface which uses the
Access 2010 Navigation Control, I cannot find a way through VBA of
saying "Activate the third tab" or whatever.

So, how do I programmatically replicate the user action of clicking a
tab and thus changing the displayed subform?

I can set the NavigationForm object's SourceObject property, but this
doesn't affect which tab is shown as selected, and I'm guessing I
don't need to be manually setting colours to imply that the selected
tab has changed?!!

Thanks for your help.

Andrew

Albert D. Kallal

unread,
Oct 22, 2010, 11:23:35 AM10/22/10
to
?"andrewmrichards" wrote in message
news:003294ae-fa4b-43cb...@s4g2000yql.googlegroups.com...

>So, how do I programmatically replicate the user action of clicking a
>tab and thus changing the displayed subform?

DoCmd.BrowseTo acBrowseToForm, "Form3", "Navigation
Form.NavigationSubForm"


Form3 is the name of the sub-form you want to make active. If the sub-form
exists, then the active tab in the navigation control will change.

If the sub-form does not exist, then the current active one is REPLACED with
what you specify in the above.


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenos...@msn.com

Albert D. Kallal

unread,
Oct 22, 2010, 11:38:16 AM10/22/10
to
?"Albert D. Kallal" wrote in message
news:V%hwo.15409$FM2....@newsfe16.iad...

(If the sub-form does not exist, then the current active one is REPLACED
with
what you specify in the above.)

Sorry, the above should read:

if the sub-form (form or report name you want to display) is NOT in the
current list of navigation buttons, then the current active navigation
control is replaced with what you specify in the above.

So, of course the form has to exist, but I meant to say exists as an
legitimate choice in the current set of buttons you have in the navigation
control.

So, in any case where the form you specify with browse to exists, then the
corresponding button does become active and highlighted.

andrewmrichards

unread,
Oct 23, 2010, 11:43:57 AM10/23/10
to
On Oct 22, 4:38 pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal...@msn.com>
wrote:
> ?"Albert D. Kallal"  wrote in messagenews:V%hwo.15409$FM2....@newsfe16.iad...
> Pleasenospam_kal...@msn.com

Excellent - Thank you so much for that Albert.

Worked like a charm...

Andrew

Dean H

unread,
Sep 4, 2014, 5:24:15 PM9/4/14
to
So, I've got the same problem as Andrew, except all of my navigation buttons are "unbound"--that is, the NavigationTarget property of each button is empty--so the above solution won't work since there is no "legitimate" form identified behind any of the buttons.

For background, I'm working on an application that has about 30 lookup tables that need to be editable by the user. I have developed a generic, reusable list form that displays the contents of a selected lookup table and allows the user to make changes as necessary to the data. The properties for this generic list form (such as the listbox rowsource, visibility of certain controls, etc.) get loaded on the fly through vba code, and vary depending on what lookup table is being loaded into the form. This saves me from having to create 30 different list forms, one for each lookup table. I have also developed a generic Navigation Form, with 10 NavigationButton controls that have code behind them to load a specific lookup table into the generic list form and display it in the NavigationSubform control. Since I only have 10 buttons on the form, I have also placed "page" controls on the form that essentially allow me to split the 30+ lookup tables across four different "pages", in groups of 10 (i.e., "Page 1" displays controls to modify lookup tables 1-10, "Page 2" shows 11-20, etc.; in reality, the captions and code behind the 10 NavigationButton controls are being modified by code on the fly to display the appropriate set of lookup tables).

The setup works perfectly except when I switch pages, and the code behind the form loads a new set of 10 lookup tables into the NavigationButtons. By default, I want the first lookup table on the page to be displayed in the NavigationSubform control when the page opens. However, if another NavigationButton was already selected on the previous page, that button remains highlighted when I switch pages, leading to inconsistency between the selected button and the actual lookup table that is being displayed. I need a way to programmatically highlight the first NavigationButton control on the form when a page change is executed.

Any suggestions? As Andrew mentioned, I don't think I should have to get into manually adjusting the colors and shading of the buttons to simulate "activation" of a particular button.

I'm sorry for the long post, but it's hard to explain. I also realize this thread is 4 years old, so if I don't get a response, I'll try posting a new thread elsewhere!

Thanks,
Dean
0 new messages