Combo box query retreival

L

lordjeffj

Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
O

Ofer Cohen

You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))
 
K

Klatuu

In design view of the combo box, set the RowSource Type property to Value
List and leave the RowSource property blank.
Then in the form load event:

Private Sub Form_Load()
Dim qdfs As QueryDefs
Dim qdf As QueryDef
Dim strQry As String

Set qdfs = CurrentDb.QueryDefs
For Each qdf In qdfs
If Left(qdf.Name, 1) <> "~" Then 'Filter out internal queries
strQry = strQry & qdf.Name & ";"
End If
Next qdf
strQry = Left(strQry, Len(strQry) - 1)
Me.Combo23.RowSource = strQry
Set qdfs = Nothing
Set qdf = Nothing
End Sub
 
S

Sara Sun

I am having the same issue here. this code worked but
i am trying to use only select queries & this code picks ups all the delete
query, update queries etc. How to restict this coding to only the select
queries ??

Ofer Cohen said:
You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))

--
Good Luck
BS"D


lordjeffj said:
Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
K

Klatuu

The only way you can do that is with good naming conventions. There is no
property that tells what kind of query it is. If you use the convention where
Select starts wit qsel
Update = qupd
Delete = qdel
Append = qapp
Make Table = qmak

Then you can test for that.

Sara Sun said:
I am having the same issue here. this code worked but
i am trying to use only select queries & this code picks ups all the delete
query, update queries etc. How to restict this coding to only the select
queries ??

Ofer Cohen said:
You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))

--
Good Luck
BS"D


lordjeffj said:
Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
S

Sara Sun

with 100s of existing queries i think it is gonna be hard change this
existing way of naming conventions.

Sara

Klatuu said:
The only way you can do that is with good naming conventions. There is no
property that tells what kind of query it is. If you use the convention where
Select starts wit qsel
Update = qupd
Delete = qdel
Append = qapp
Make Table = qmak

Then you can test for that.

Sara Sun said:
I am having the same issue here. this code worked but
i am trying to use only select queries & this code picks ups all the delete
query, update queries etc. How to restict this coding to only the select
queries ??

Ofer Cohen said:
You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))

--
Good Luck
BS"D


:

Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
K

Klatuu

Sorry, there isn't really any other way that I know of.

Sara Sun said:
with 100s of existing queries i think it is gonna be hard change this
existing way of naming conventions.

Sara

Klatuu said:
The only way you can do that is with good naming conventions. There is no
property that tells what kind of query it is. If you use the convention where
Select starts wit qsel
Update = qupd
Delete = qdel
Append = qapp
Make Table = qmak

Then you can test for that.

Sara Sun said:
I am having the same issue here. this code worked but
i am trying to use only select queries & this code picks ups all the delete
query, update queries etc. How to restict this coding to only the select
queries ??

:

You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))

--
Good Luck
BS"D


:

Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
S

Sara Sun

thanks for trying anyway.

Sara

Klatuu said:
Sorry, there isn't really any other way that I know of.

Sara Sun said:
with 100s of existing queries i think it is gonna be hard change this
existing way of naming conventions.

Sara

Klatuu said:
The only way you can do that is with good naming conventions. There is no
property that tells what kind of query it is. If you use the convention where
Select starts wit qsel
Update = qupd
Delete = qdel
Append = qapp
Make Table = qmak

Then you can test for that.

:

I am having the same issue here. this code worked but
i am trying to use only select queries & this code picks ups all the delete
query, update queries etc. How to restict this coding to only the select
queries ??

:

You can use the MSysObjects table, use this SQL as the combo RowSource

SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=5) AND ((Left([Name],1))<>"~"))

--
Good Luck
BS"D


:

Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
Top