<Add New> in Combo Box Not Displayed

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

I have a combo box with the following as its row source:

SELECT -1 as AddNewChoice, "<add new client>" as Bogus FROM
[tblClients] UNION SELECT [tblClients].[intClientID],
[tblClients].[strName] FROM [tblClients] ORDER BY [strName];

When tblClients has records in it, <add new client> is displayed at the
top of the combo box as desired. However, if tblClients is empty, <add
new client> is not displayed. What is wrong here?

Thanks,
Patrick
 
The reason is that, if tblClients is empty, then any select command based on
it is going to retrieve nothing. The easy way around it is just to replace
the first from clause with a table which is guaranteed to contain records,
or maybe just create a dummy table purely for the purpose.
 
Thanks for the input. Here is the updated, working query:

SELECT -1 as AddNewChoice, "<add new client>" as Bogus FROM
[Switchboard Items] UNION SELECT [tblClients].[intClientID],
[tblClients].[strName] FROM [tblClients] ORDER BY [strName];

As you can see, the first SELECT query is using Switchboard Items as
its FROM because I know that this table will always have items in it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top