Select Query To Use From Combo

dubiousp

Member
Local time
Today, 00:37
Joined
Mar 6, 2020
Messages
86
Good morning I have db with many records,, using a form I have programmed the tb to enter data for a criteria which works well...

Is there a way of using a combo to select a query already set,, for example I have 4 queries each setting 3 differing results can I use theese as a combo item
 
the query for the combo would read a table with 2 columns:
caption, Qry

the caption is what the user will see , the query is that gets run.
set the combo props: columns=2, widths: 1;0, the data column is bound to col.2 (qry)

the code below sets the form to the query

Code:
sub cboBox_afterupdate()
   subform.sourceobject = "query." & cboBox
end sub
 
Ok so if I understand correctly I use a table to hold the text of the query so 4 queries would be four columns the combo then selects
 
so 4 queries would be four columns the combo then selects
No, four rows. Combo boxes number columns starting from zero. Column(0) of the selected row would be a name or other indicator of what the query represents. Column(1) would be the complete text of the query for that one row that you select.

There is an implication here. For this to make any sense whatsoever, the four queries must differ ONLY in the WHERE clauses or ORDER BY clauses. OR the field names for the queries involved ALL have to match .RecordSource names for the sub-form. Otherwise, the table's fields will not bind correctly to the sub-form.

Side note: It is not considered polite to cross-post (to another forum) without revealing that point on BOTH forums. Otherwise we waste time answering a question that has already been answered.
 

Users who are viewing this thread

Back
Top Bottom