PDA

View Full Version : Set combobox rowsource from querydef and add extra item



kunguito
08-29-2008, 02:09 AM
Hi,
The following code assigns the result of a query to a combobox.

Dim qdf As QueryDef
Dim cbobox As Combobox
Dim parameterZero As String, parameterOne as String
Set qdf = CurrentDb.QueryDefs(NameOfUserDesignedQuery)
qdf.Parameters(0) = parameterZero
qdf.Parameters(1) = parameterOne
Set cbobox.Recordset = qdf.OpenRecordset
Set qdf = Nothing
Quetsion: How can I now add to the values an extra item, for example "all" if the combobox datasource type is set to Table or query?


Thanks

Mavyak
08-29-2008, 07:14 AM
You can union your existing query with another query that selects the hard-coded value 'all' and then use the union query as your source for the combo box.