Trying to add a placeholder value to a combobox in Access VBA


  • 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."


    Any thoughts?

    Tuesday, July 22, 2008 3:23 PM

All replies

  • Hi


    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
    Tuesday, July 22, 2008 4:15 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?

    Tuesday, July 22, 2008 5:33 PM
  • I have a workaround to it.  Just add a space before "Select Name" and it shot right up to the top of the list.


    There has got to be a more reliable way of doing that however.


    Tuesday, July 22, 2008 6:06 PM
  • Hi


    I normally cheat and put a space at the beginning i.e. " Select Name". Have you tried puting the order by in the sub query and not using order by in the combobox?


    • Proposed as answer by Maisikeli Wednesday, September 02, 2009 3:21 PM
    Wednesday, July 23, 2008 8:24 AM
  • 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.
    Wednesday, September 02, 2009 3:31 PM