Add item to combo box listing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a combo box who's source is a table. I would like to know how I can
add an item to the combo box listing without added it to the table?

Thanks

Daniel
 
Provide more info, please. Should this item be shown in the list always, or
just after you type a new entry into the combo box?
 
You can do it with a union query ...

SELECT "(All)" FROM Employees
UNION SELECT LastName
FROM Employees;

This looks a little odd, because "(All)" is not in the Employees table, but
in Jet SQL every SELECT clause must have a FROM clause, and this satisfies
that requirement.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Yes, I would like the item to always appear as an item in the combo box's
listing of choices but not as part of the table from which it populates the
combo box.

Daniel
 
I currently have the following Row source for my combo box:

SELECT [Leaders Tbl].Name, [Employee Listing Tbl].[Active Employee]
FROM [Employee Listing Tbl] INNER JOIN [Leaders Tbl] ON [Employee Listing
Tbl].Name = [Leaders Tbl].Name
WHERE ((([Employee Listing Tbl].[Active Employee])=True));

and would like to add to the retrieved list of choices, the choice "Lead
Authorized". Could you show me what to do.

Thank you

Daniel
 
I had to use different tables and fields, because I didn't want to post a
reply without testing it, and obviously I don't have your tables available
for testing. So I used the Order Details and Orders tables from the
Northwind sample database ...

SELECT [Order Details].OrderID, Products.ProductName
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order
Details].ProductID
WHERE ((([Order Details].Discount)<>0))
UNION SELECT 1, "(All)" FROM Products;

It might be simpler if you save your existing SQL statement as a saved
query. Then the SQL for the UNION query will become more like ...

SELECT [Name], [Active Employee] FROM YourSavedQuery
UNION SELECT "Lead Authorised", "Whatever" FROM SomeTable

Remember that the number of fields in the two select statements must match.
If you're selecting two fields in the first select statement, you can't add
just "Lead Authorised" in the second select statement, you must add "Lead
Authorised" *and* something to match the other field in the first select
statement.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Daniel said:
I currently have the following Row source for my combo box:

SELECT [Leaders Tbl].Name, [Employee Listing Tbl].[Active Employee]
FROM [Employee Listing Tbl] INNER JOIN [Leaders Tbl] ON [Employee Listing
Tbl].Name = [Leaders Tbl].Name
WHERE ((([Employee Listing Tbl].[Active Employee])=True));

and would like to add to the retrieved list of choices, the choice "Lead
Authorized". Could you show me what to do.

Thank you

Daniel




Brendan Reynolds said:
You can do it with a union query ...

SELECT "(All)" FROM Employees
UNION SELECT LastName
FROM Employees;

This looks a little odd, because "(All)" is not in the Employees table,
but
in Jet SQL every SELECT clause must have a FROM clause, and this
satisfies
that requirement.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible
for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top