f



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

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
3
andrewmrichards
10/21/2010 10:36:47 PM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

4 Replies
6561 Views

Similar Articles

[PageSpeed] 52

?"andrewmrichards"  wrote in message=20
news:003294ae-fa4b-43cb-a627-dac54afa8218@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=20
Form.NavigationSubForm"


Form3 is the name of the sub-form you want to make active. If the =
sub-form=20
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=20
what you specify in the above.


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

0
Albert
10/22/2010 3:23:35 PM
?"Albert D. Kallal"  wrote in message=20
news:V%hwo.15409$FM2.6652@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=20
current list of navigation buttons, then the current active navigation=20
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=20
legitimate choice in the current set of buttons you have in the =
navigation=20
control.

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

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



0
Albert
10/22/2010 3:38:16 PM
On Oct 22, 4:38=A0pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal...@msn.com>
wrote:
> ?"Albert D. Kallal" =A0wrote in messagenews:V%hwo.15409$FM2.6652@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 navigatio=
n
> control.
>
> So, in any case where the form you specify with browse to exists, then th=
e
> corresponding button does become active and highlighted.
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> Pleasenospam_kal...@msn.com

Excellent - Thank you so much for that Albert.

Worked like a charm...

Andrew
0
andrewmrichards
10/23/2010 3:43:57 PM
On Friday, October 22, 2010 10:38:16 AM UTC-5, Albert D. Kallal wrote:
> ?"Albert D. Kallal"  wrote in message=20
> news:V%hwo.15409$FM2.6652@newsfe16.iad...
>=20
> (If the sub-form does not exist, then the current active one is REPLACED=
=20
> with
> what you specify in the above.)
>=20
> Sorry, the above should read:
>=20
> if the sub-form (form or report name you want to display) is NOT in the=
=20
> current list of navigation buttons, then the current active navigation=20
> control is replaced with what you specify in the above.
>=20
> So, of course the form has to exist, but I meant to say exists as an=20
> legitimate choice in the current set of buttons you have in the navigatio=
n=20
> control.
>=20
> So, in any case where the form you specify with browse to exists, then th=
e=20
> corresponding button does become active and highlighted.
>=20
> --=20
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> Pleasenospam_kallal@msn.com

So, I've got the same problem as Andrew, except all of my navigation button=
s are "unbound"--that is, the NavigationTarget property of each button is e=
mpty--so the above solution won't work since there is no "legitimate" form =
identified behind any of the buttons. =20

For background, I'm working on an application that has about 30 lookup tabl=
es that need to be editable by the user.  I have developed a generic, reusa=
ble list form that displays the contents of a selected lookup table and all=
ows the user to make changes as necessary to the data.  The properties for =
this generic list form (such as the listbox rowsource, visibility of certai=
n controls, etc.) get loaded on the fly through vba code, and vary dependin=
g on what lookup table is being loaded into the form.  This saves me from h=
aving to create 30 different list forms, one for each lookup table.  I have=
 also developed a generic Navigation Form, with 10 NavigationButton control=
s that have code behind them to load a specific lookup table into the gener=
ic 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 for=
m that essentially allow me to split the 30+ lookup tables across four diff=
erent "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 an=
d code behind the 10 NavigationButton controls are being modified by code o=
n the fly to display the appropriate set of lookup tables). =20

The setup works perfectly except when I switch pages, and the code behind t=
he 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 Navigat=
ionButton was already selected on the previous page, that button remains hi=
ghlighted when I switch pages, leading to inconsistency between the selecte=
d button and the actual lookup table that is being displayed.  I need a way=
 to programmatically highlight the first NavigationButton control on the fo=
rm when a page change is executed. =20

Any suggestions?  As Andrew mentioned, I don't think I should have to get i=
nto manually adjusting the colors and shading of the buttons to simulate "a=
ctivation" 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 ne=
w thread elsewhere!

Thanks,
Dean
0
Dean
9/4/2014 9:24:15 PM
Reply: