Full Version: Adding A Blank Selection To Combo Box
UtterAccess Forums > Microsoft® Access > Access Forms
ddaddy
I have a bound combo box who's source is a SELECT query with a WHERE clause.
How can I add a blank entry to the combo box, so the user doesn't have to select an item from the list, yet still keeping the 'Limit to List' enabled.
Thanks
argeedblu
You would use a UNION query to add the entry. I don't know your actual field names but the query would look something like this:
SELECT fu, bar FROM tblFuBar
UNION
SELECT null, " " FROM tblFBar.
Selects after the UNION must have the same number of fields and the main query.
Glenn
ddaddy
Thanks for your response.
What table would be used for the 2nd SELECT with the null?
pere_de_chipstick
Hi ddaddy
I use the On Double Click Event to clear the combo box:
Me.ComboBoxName = Null
Then when referring to the combo box
IntCmbVal = NZ(Me.ComboBoxName,0)
CAn alternative might be to use a Union query
SELECT * FROM YourTableName
UNION
SELECT 0, ""
FROM YourTableName
Orderbr /> use the On Double Click Event to clear the combo box:
Me.ComboBoxName = Null
Then when referring to the combo box
IntCmbVal = NZ(Me.ComboBoxName,0)
CAn alternative might be to use a Union query
SELECT * FROM YourTableName
UNION
SELECT 0, ""
FROM YourTableName
ORDER BY YourIDFieldName
hth
Edit: replace 'Union all' by 'Union' in sql
argeedblu
It seems odd, I know, but you can use your the same table name as in the first select clause. I had a typo in my union query so the second table should have been tblFuBar.
Glenn
ddaddy
Spot on, thank you :-)
argeedblu
You are most welcome.
Glenn
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.