List of queries and tables in a combobox

Anonymous_354

Duct tape lovers UNITE!
Local time
Yesterday, 21:32
Joined
Jun 6, 2007
Messages
74
If this has been answered before, I'm sorry for the inconvenience.

I need to get a list of my tables and queries in a combobox and be able to have a button (or I could just hit enter) near the combobox that will start the approperate table/query.

I'm actually using this for both Access 2000 and VB.NET, but I'll do my best to translate.

Did any of that make sense?
 
Last edited:
In the combobox's property box, got Data then set the Row Source Type to Tables/Queries and place this in the RowSource box:

SELECT [MSysObjects].[Name] FROM MSysObjects WHERE ((([MSysObjects].[Name]) Not Like "~*" And [Name] Not Like 'MSys*') And (([MsysObjects].[Type])=5 Or ([MsysObjects].[Type])=1));

This will pull up a list of quesries and tables in the combobox.

Here's a bit of a kludge, but it will do the job. I'm not sure exactly how to determine the objecttype of the returned table/query, so this code attempts to open it as a table, and if that fails, goes to the error handler, which opens it as a query. Replace ComboTablesAndQueries with the actual name of your combobox.

Code:
Private Sub ComboTablesAndQueries_AfterUpdate()
On Error GoTo Err_ComboTablesAndQueries_Click
  
DoCmd.OpenTable ComboTablesAndQueries

Exit_ComboTablesAndQueries_Click:
    Exit Sub

Err_ComboTablesAndQueries_Click:
    DoCmd.OpenQuery ComboTablesAndQueries
End Sub
Good Luck!
 
Last edited:
Thanks Missinglinq! I'll go try it.

That doesn't look like VB.NET. Does anyone know how to do this in C# OR VB.NET?

Admins, if you deem this in the wrong forum, by all means please move it.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom