Combo Box Help

  • Thread starter Thread starter CY
  • Start date Start date
C

CY

I have a combo box that I would like to display "Select a Utility Company"
if nothing has been selected yet. The only way I have figured out to do it,
is to add it to the underlying table but since this combo box is filtered
depending on other criteria (one of them being State) I would have to add it
52 times to the underlying table and it seems messy. Surely there's another
way to do it??? Anyone have any ideas?

TIA!
 
Assuming the current combo rowsource SQL is:

SELECT Table1.FieldX, yada yada FROM Table1
WHERE yada yada yada

start making a new query in design view, add no table, revert to SQL
view, and type in / paste:

SELECT " Select a Utility Company", "", ""

UNION SELECT Table1.FieldX, yada yada FROM Table1
WHERE yada yada yada

Save the query, and make it the combo's rowsource.
Notes:
In the first Select, there must be as many "" (zero length strings)
following the fixed text as required to match the number of fields in
the second select less 1, so the two SELECT's end up having the same
number of fields returned.
Notice the leading space in the " Select a Utility Company"; this is so
this one comes on top of the list (assuming ascending sorting on this
field).

HTH,
Nikos
 
I finally got around to trying this but I get an error that says "Query
input must contain at least one table or query" What did I do wrong?
 
You did nothing wrong, I did! I missed out a part in the first SELECT of
the union query. It should be:

SELECT " Select a Utility Company", "", "" FROM Table1

UNION SELECT Table1.FieldX, yada yada FROM Table1
WHERE yada yada yada

Also, in order to get the " Select a Utility Company" to display until a
selection is made, you need to put it in the combo's Default Value
property (exactly as it appears in the union query, with the quotes).

Sorry for the confusion! HTH,
Nikos
 
Back
Top