I have a combobox in a form that is populated by a Query. What I would like to do is add a "Select Name" Place holder value as the initial item seen in the combobox. I can get "Select Name" as the Default Value, but nothing will pop up in the actual text portion of the combobox. I have also tried juts setting the Text property of the combobox to "Select Name" but I run into this runtime error:
"You can't reference a property or method for a control unless the control has the focus."
I have a workaround if your query is static, i.e. not changed by your VBA. Create a Table with one record ([Select Name]), in SQL mode in query design create a Union query for this table and your currrent query. Use this new union query as the data for your combobox. Your union query might look something like below, where table1 is the new table and Query15 is your existing query
TABLE [table1] UNION ALL SELECT * FROM Query15;
- Proposed as answer by Maisikeli Wednesday, September 02, 2009 3:21 PM
It is working!
But there is one minor hitch to it. I have the combobox sorted by name, and while the "Select Name" placeholder does show up and I can get the combobox to show that value upon the loading of the form, the "Select Name" placeholder doesn't show up on the top of the list due to my order by. Is there a way to exclue the "Select Name" from that Order By statement?
Instead of adding a space at the beginning, use braces/parenthesis to enclose the item e.g. "(Select Name)". This will place this item above all other items in the list. Reason? well ASCII value for "(" is 40 while that of "A" is 65. Regardless of the text enclosed, the enclosed item will always be at the top.