3

In Microsoft Access 2007, in the VBA Code, one can know the Object selected through a single-click in the Navigation Pane by:

dim strObjName as String, lObjType as Long
strObjName = Application.CurrentObjectName
lObjType = Application.CurrentObjectType

Only a single object can be selected in this way.

Now I want to select multiple objects, for example, to export several selected tables from the backend SQL Server that is used for our physical store managing, as .sql text files to create MySQL tables for website usage.

Here is the screenshot: In the Navigation Pane, try to get the selected objects marked by brown bg color.

screenshot

My question is, in Visual Basic for Application, how to get the list of objects selected in the navigation pane through Shift-Click, so several objects are simultaneously selected, as shown in fig., that Access 2007 marks by brown background color, in a way like:

dim xObjs
Set xObjs = Application.SelectedObjects ' this property does not exist.

?

Community
  • 1
  • 1
jacouh
  • 8,473
  • 5
  • 32
  • 43

1 Answers1

4

I don't believe there's a collection object for the Navigation bar, which would probably be your only hope in this case.

I suggest you create your own form with a multi-select listbox, fill it out with your Query objects when the form loads, and then write code to loop through the listbox and export the selected items.

HK1
  • 11,941
  • 14
  • 64
  • 99
  • Thanks HK1 for your rapid reply. I use in effet your idea for exporting tables from SQL Sever to our MySQL Database from Microsoft Access 2007. I think, as Access marks multiple selected objects, so it's conscient of the user selection. I should prefer a VBA system Collection to handle the tables/queries list, related to the Navigation Pane. – jacouh Sep 17 '13 at 08:06
  • It doesn't matter what you're preference is, you have to work with the objects and methods that are exposed by the interfaces your programming in. I haven't found any documentation to indicate that the Navigation Bar has a collection object that lets you access all selected items. Perhaps it exists and I'm just unaware of it. Try using the Object Browser inside the Code View Window. Search for Navigation or Look under the Access Library to see if you can find something yourself. – HK1 Sep 17 '13 at 12:40
  • OK. But maybe somebody has a miraculous solution to share with us... I'm waiting for some time. – jacouh Sep 17 '13 at 15:49
  • I've searched "NavigationPane", "Pane", "Selected", "Current", under VBA Objects Explorer, Nothing is found interesting for the .SelectedObjects like property/method. – jacouh Sep 19 '13 at 16:51