Combo Box Query Value

G

Guest

I was wondering if there is a way to be able to choose which queries I want in the drop down box instead of all of them. The code is below that I have to receive all queries in the drop down box.

Thanks,

-Mat

----- Graham R Seach wrote: ----

Matt

There's no way the query you used can return every report, query and table
Specifying Type=5 filters it to return only query names. Check again

SELECT [Name] FROM MSysObject
WHERE [Type] =
ORDER BY [Name

As for running the selected query, this code will do it
Private Sub cboMyCombo_AfterUpdate(
If Not IsNull(Me!cboMyCombo) The
CurrentDb.Execute Me!cboMyCombo.Value, dbFailOnErro
End I
End Su

Regards
Graham R Seac
Microsoft Access MV
Sydney, Australi

Microsoft Access 2003 VBA Programmer's Referenc
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.htm


Matt said:
queries appear in a dropdown box, and then run a command button/report fro
the selection of the query. I tried the following code but it gives m
every report, query, table, etc etc in my dropdown box. Is there a way t
pick which queries I want in my dropdown? Thank you very much
Set the combo box Row Source Type property to Table/Query Set the Rowsource to
SELECT MSysObjects.Name FROM MSysObjects WHER
(((Left([Name] said:
Set the bound column to 1
Set the ColumnWidths property to 1
Set the LimitTo List to Yes
Set the AutoExpand to Yes
Then, if you wanted to run any one particular query, based upon i
being selected in this combo box, code the AfteUpdate event
DoCmd.OpenQuery Me!ComboNam
 
J

John Vinson

I was wondering if there is a way to be able to choose which queries I want in the drop down box instead of all of them. The code is below that I have to receive all queries in the drop down box.

If you have a naming convention for queries, you can put a criterion
on the [Name] field to limit it to those that match the desired names.
Alternatively, and less restrictively, you could just create a table
of query names and maintain it separately.
 
G

Guest

Thanks John, here is what I did.

SELECT MSysObjects.Name FROM MSysObjects WHERE (((Left([Name],1))<>"~") AND ((Left([Name],10))<>"CountyName") AND ((Left([Name],12))<>"Agribusiness") AND ((Left([Name],6))<>"County") AND ((Left([Name],16))<>"employment_naics") AND ((Left([Name],3))<>"EST") AND ((Left([Name],4))<>"Food") AND ((Left([Name],3))<>"Ind") AND ((Left([Name],3))<>"Man") AND ((Left([Name],5))<>"NAICS") AND ((Left([Name],3))<>"non") AND ((Left([Name],9))<>"wholesale") AND ((MSysObjects.Type)=5)) ORDER BY MSysObjects.Name

ya it's a little sloppy but it got the job done. thanks again!

----- John Vinson wrote: ----

I was wondering if there is a way to be able to choose which queries I want in the drop down box instead of all of them. The code is below that I have to receive all queries in the drop down box.

If you have a naming convention for queries, you can put a criterio
on the [Name] field to limit it to those that match the desired names
Alternatively, and less restrictively, you could just create a tabl
of query names and maintain it separately

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=publi
 
G

Graham R Seach

Matt,

So rather than continue with your original thread, you abandon it to begin a
new one! Not very impressive!

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Matt said:
I was wondering if there is a way to be able to choose which queries I
want in the drop down box instead of all of them. The code is below that I
have to receive all queries in the drop down box.
Thanks,

-Matt

----- Graham R Seach wrote: -----

Matt,

There's no way the query you used can return every report, query and table.
Specifying Type=5 filters it to return only query names. Check again!

SELECT [Name] FROM MSysObjects
WHERE [Type] = 5
ORDER BY [Name]

As for running the selected query, this code will do it:
Private Sub cboMyCombo_AfterUpdate()
If Not IsNull(Me!cboMyCombo) Then
CurrentDb.Execute Me!cboMyCombo.Value, dbFailOnError
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Matt said:
the
queries appear in a dropdown box, and then run a command button/report from
the selection of the query. I tried the following code but it gives me
every report, query, table, etc etc in my dropdown box. Is there a way to
pick which queries I want in my dropdown? Thank you very much.
Set the combo box Row Source Type property to Table/Query. Set the Rowsource to:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name] said:
Set the bound column to 1.
Set the ColumnWidths property to 1"
Set the LimitTo List to Yes.
Set the AutoExpand to Yes.
Then, if you wanted to run any one particular query, based
upon it
being selected in this combo box, code the AfteUpdate event:
DoCmd.OpenQuery Me!ComboName
 

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

Top