Can I Choose from list of Queries in Combobox

cindy007

Hit n Miss
Local time
Today, 18:02
Joined
Dec 11, 2002
Messages
16
Hi,
I was wondering if it was at all possible to have a list of queries in a CombBox and be able to choose one to run. (Based on the same table, but displaying a different field's records in the different queries)

Cindy
 
Cindy,

Yes.

A very simple solution: Create and save your queries using the Access query grid. Then fill your combo value list with query names fit for user eyes before putting code similar to the following in the Change Event of your combo box.

Code:
'Which query was selected?
   Select Case Me.ComboBoxName.Value

'The month-end query?
	Case "Month End"
	DoCmd.OpenQuery "QryMonthEnd"

'The Year-end query?
	Case "Year End"
	DoCmd.OpenQuery "QryYearEnd"

'The YTD Summary?
	Case "YTD Summary"
	DoCmd.OpenQuery "QryYTDSum"

   End Select

A more sophisticated method might involve filling your combo box from a table that has generic, user-friendly query names in one column and the actual query name in another column. See the following properties in Help for more info: "row source" and "Column Count" and "Column Widths" and "Bound Column."

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom