NavigateTo Question

J

JamesJ

2 thing of interest here.
This is apparently wrong 'cause I'm getting a compile error:
DoCmd.NavigateTo([Custom], [Data01]) Expected =

1) While I type it in the Auto Data Tips (I think that's what it is called)
is Showing the following:
DoCmd.NavigateTo([Category], [Group])

2) When I do vb help for the NavigateTo Method it's example is:
DoCmd.NavigateTo(Category, Group) minus the brackets being
shown in the Auto Data Tips.

What is the proper sysntax? The Category is Custom and the Group is Data01.

Thanks,
James
 
A

Allen Browne

James, I will check into this further, but a cursory glance suggests that
the NavigateTo method is faulty.

It's a new method of the DoCmd object in A2007, for manipulating the
Navigation Pane. The NavigateTo action in a macro works okay. If you show
the Arguments column in macro design, you see arguments such as
acNavigationCategoryObjectType, acNavigationGroupTables

If you then open the Object Browser (F2 in the code window), show hidden
members (right-click) and search for acNavigationCategoryObjectType, it
doesn't exist. Similarly, if you ask this in the Immediate Window:
? TypeName(acNavigationCategoryObjectTy)
the response is Empty, indicating it is an uninitialized variant, i.e. VBA
does not recognise it as a defined constant.

So, it appears that the constants are not correctly declared for use in VBA
code.

The only way I can see that you can call them programatically at this point
would be RunMacro.
 
J

JamesJ

I'll do the macro.

Thanks much,
James

Allen Browne said:
James, I will check into this further, but a cursory glance suggests that
the NavigateTo method is faulty.

It's a new method of the DoCmd object in A2007, for manipulating the
Navigation Pane. The NavigateTo action in a macro works okay. If you show
the Arguments column in macro design, you see arguments such as
acNavigationCategoryObjectType, acNavigationGroupTables

If you then open the Object Browser (F2 in the code window), show hidden
members (right-click) and search for acNavigationCategoryObjectType, it
doesn't exist. Similarly, if you ask this in the Immediate Window:
? TypeName(acNavigationCategoryObjectTy)
the response is Empty, indicating it is an uninitialized variant, i.e. VBA
does not recognise it as a defined constant.

So, it appears that the constants are not correctly declared for use in
VBA code.

The only way I can see that you can call them programatically at this
point would be RunMacro.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JamesJ said:
2 thing of interest here. This is apparently wrong 'cause I'm getting a
compile error:
DoCmd.NavigateTo([Custom], [Data01]) Expected =

1) While I type it in the Auto Data Tips (I think that's what it is
called)
is Showing the following:
DoCmd.NavigateTo([Category], [Group])

2) When I do vb help for the NavigateTo Method it's example is:
DoCmd.NavigateTo(Category, Group) minus the brackets being
shown in the Auto Data Tips.

What is the proper sysntax? The Category is Custom and the Group is
Data01.

Thanks,
James
 
A

Allen Browne

Actually, it turns out that my initial guess was wrong.

The names such as acNavigationCategoryObjectType and acNavigationGroupTables
are not meant to be constants. They are the literal strings that NavigateTo
expects.

So DoCmd.NavigateTo does work in code, if you use those names in quotes. The
help topic doesn't explain this, so you need to mock up a macro with the
desired choices, and display them in the macro names argument. You can then
copy these names as string into your code.

Strange one! Certainly not well documented.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JamesJ said:
I'll do the macro.

Thanks much,
James

Allen Browne said:
James, I will check into this further, but a cursory glance suggests that
the NavigateTo method is faulty.

It's a new method of the DoCmd object in A2007, for manipulating the
Navigation Pane. The NavigateTo action in a macro works okay. If you show
the Arguments column in macro design, you see arguments such as
acNavigationCategoryObjectType, acNavigationGroupTables

If you then open the Object Browser (F2 in the code window), show hidden
members (right-click) and search for acNavigationCategoryObjectType, it
doesn't exist. Similarly, if you ask this in the Immediate Window:
? TypeName(acNavigationCategoryObjectTy)
the response is Empty, indicating it is an uninitialized variant, i.e.
VBA does not recognise it as a defined constant.

So, it appears that the constants are not correctly declared for use in
VBA code.

The only way I can see that you can call them programatically at this
point would be RunMacro.

JamesJ said:
2 thing of interest here. This is apparently wrong 'cause I'm getting a
compile error:
DoCmd.NavigateTo([Custom], [Data01]) Expected =

1) While I type it in the Auto Data Tips (I think that's what it is
called)
is Showing the following:
DoCmd.NavigateTo([Category], [Group])

2) When I do vb help for the NavigateTo Method it's example is:
DoCmd.NavigateTo(Category, Group) minus the brackets being
shown in the Auto Data Tips.

What is the proper sysntax? The Category is Custom and the Group is
Data01.
 
Joined
May 30, 2012
Messages
1
Reaction score
0
I have been toiling with the NavigateTo method and thanks to a Google Book discovered the correct syntax. I created a small form with a button for the most common objects. As I click each button, the various objects appear in the Navigation Pane. Here is the code behind the buttons. Note that I had to make sure the Pane was maximised before displaying the objects. I also added buttons to show all the objects and to hide the Pane. It works a treat and is handy if you have a lot of tables, queries etc. I also attach a database with the Form if anyone wants to use/amend it.

Private Sub Command0_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupTables"
End Sub
Private Sub Command2_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupQueries"
End Sub
Private Sub Command3_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupForms"
End Sub
Private Sub Command4_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupMacros"
End Sub
Private Sub Command5_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupModules"
End Sub
Private Sub Command6_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType" ' All Objects
DoCmd.Maximize
End Sub
Private Sub Command7_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Maximize
DoCmd.NavigateTo "acNavigationCategoryObjectType", "acNavigationGroupReports"
End Sub
Private Sub Command8_Click()
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Minimize
End Sub
Private Sub Form_Load()
DoCmd.MoveSize 0, 0, , 850
End Sub
 

Attachments

  • Navigation.zip
    14.2 KB · Views: 224

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top