Combo to choose queries

kupe

Registered User.
Local time
Today, 10:58
Joined
Jan 16, 2003
Messages
462
Can a combo be used to select different queries in its drop-down list, can anyone tell me, please?
 
Yes and No. Depends on what you are trying to do. A combobox can act like a selection for a specific query to run, but you most likely will need something else to apply that selection. Think of the combobox as a pointer to (I want to use that one) and something like VBA or a macro condition implementing that pointer.
 
Thanks, Fofa. Yes, I use them for choosing a specific record(s) from one form's offerings.

The current need is that the combobox should have the names of queries, and to be able to choose the specific link via the combo. I've been trying to do it in the QBE mode, but so far without success.

Be grateful for any hints or suggestions for the way the code ought to go.
 
What are these queries doing/used for? besides the Combobox selecting a query, what other actions are happening?
 
Good to hear from you again, Fofa. The combo box is merely to select an individual form per record, like it might normally be used to select a record.

In this case, if the list dropping from the combo might say

frmSmartCards
frmFofasAnswer
frmAccessWorld

then choosing one of these will have that form on view. (In this instance, they will appear as subforms. The subforms part seems to be working ok. I'm using command buttons here, but the User wants to select from the combo and not cmdbuttons.) Many thanks for thinking about this. Cheers
 
OK, Simple answer, detect what is selected in the combobox ON CLICk and call the code the command button uses.

Better solution (but basically the same) detect what has been selected (notice you have to do that anyway) and run either selected vba code or macros depending on that selection. If it works from a command button you can do the same thing with the combobox, but you need to wrap something like a CASE statement around it to tell the system what to run.
 
Excellent, Fofa, thanks very much. I suspect/hope that being new to this world makes me hesitate. Of course yours is a logical process and I should have seen that. But it's a lesson learned. Most grateful. Cheers.
 
Prefix your queries with whatever you want. Typically, qry. If you only want a selection of, say four out of ten queries to appear in your combobox, then prefix those four with a specific prefix.

Then, for the combo's RowSource:

SELECT Name FROM MSySObjects WHERE Left(Name, 3) = "qry";


or something like that.
 
Thanks, Mile-O-Phile. Your help is appreciated.
 
Just in case you didn't know - the table MSysObjects is a system table that is hidden within your database. It holds info on all the objects such as forms, queries, tables, etc. that your database contains.

If you want to have a look at it then goto Tools -> Options

and select show show hidden and show system objects.
 
I didn't. Thanks. Will go there now. (Odd not to see that old icon of yours, by the way.) Cheers.
 
kupe said:
(Odd not to see that old icon of yours, by the way.)

Ok, to calm the oddness:
madnessman.gif
 
Like a breath of pure air after a smoky pub. Refreshed for the weekend, many thanks, MoP.
 

Users who are viewing this thread

Back
Top Bottom