Combo box query retreival

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could someone tell me how I can list the queries of an access database in a
combo box in my access form?
 
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))<>"~"))
 
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
 
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?
 
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?
 
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?
 
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?
 
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?
 

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

Back
Top