Populating a combo box with all queries

  • Thread starter Thread starter Bill Murphy
  • Start date Start date
B

Bill Murphy

I would like to populate a combo box on a form with all the queries in the
current database. I've defined cboQueries as a combo box on my form, and
set the Row Source Type as Value List. I've set the function GetQueries()
as the Row Source. When I compile the code I get "Method or Data Member Not
Found" in the second function for cboQueries.AddItem.

Any help would be appreciated.

Bill
____________________________________________________
Function GetQueries()

Dim accObject As Access.AccessObject
Dim x As Boolean

'Fill with queries
For Each accObject In CurrentData.AllQueries
x = AddItemToEnd(cboQueries, accObject.Name)
Next

End Function

Function AddItemToEnd(cboQueries As ComboBox, _
ByVal strItem As String)

cboQueries.AddItem Item:=strItem ' gets Method or Data Member Not
Found

End Function
 
Bill,
Set the Row Source Type to Query/Table. Then place the query below in the
Row Source:
SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((Left([Name],4))<>"MSys") AND ((MSysObjects.Type)=5))
ORDER BY MSysObjects.Name;

(be aware of the word wraping in the statement above)

HTH
Mr. B
 
Mr B,

That worked perfectly. Thanks.

Bill


Mr B said:
Bill,
Set the Row Source Type to Query/Table. Then place the query below in the
Row Source:
SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((Left([Name],4))<>"MSys") AND ((MSysObjects.Type)=5))
ORDER BY MSysObjects.Name;

(be aware of the word wraping in the statement above)

HTH
Mr. B

Bill Murphy said:
I would like to populate a combo box on a form with all the queries in the
current database. I've defined cboQueries as a combo box on my form, and
set the Row Source Type as Value List. I've set the function GetQueries()
as the Row Source. When I compile the code I get "Method or Data Member Not
Found" in the second function for cboQueries.AddItem.

Any help would be appreciated.

Bill
____________________________________________________
Function GetQueries()

Dim accObject As Access.AccessObject
Dim x As Boolean

'Fill with queries
For Each accObject In CurrentData.AllQueries
x = AddItemToEnd(cboQueries, accObject.Name)
Next

End Function

Function AddItemToEnd(cboQueries As ComboBox, _
ByVal strItem As String)

cboQueries.AddItem Item:=strItem ' gets Method or Data Member Not
Found

End Function
 
Back
Top