Combo box row source problem

  • Thread starter Thread starter Ling
  • Start date Start date
L

Ling

I have a combo box( cmbCustomerCode) which is suppossed to
show all the names of a customers.
But now, I would like to have the first row of the
combobox to be 'All'.
I do not want to manually type all the customers' names
and insert them as a value list of the combobox as it
would not be dynamic that way. (New customers added into
the database would not show up in the combobox)

Should i try AddItem()?or is there other ways to do it?

Thanx for your help...

Ling
 
Hi Ling,

I generally modify the rowsource query to be a union query which adds in the
"All" row. Here's an example that I built on a combo in the NorthWind
database. I also added a column named 'Sortparm' which is used to force the
"all" row to the top of the list.

SELECT Customers.CustomerID,
Customers.CompanyName,
2 as sortparm
FROM Customers
Union select
"0" as Customerid,
"<All Customers>" as CompanyName,
1 as sortparm
from Customers
ORDER BY
sortparm,
Customers.CompanyName;

Note that to create a union query you must use SQL view of query design.
 
whoa... it works great.... Thanx Sandra..
Ling
-----Original Message-----
Hi Ling,

I generally modify the rowsource query to be a union query which adds in the
"All" row. Here's an example that I built on a combo in the NorthWind
database. I also added a column named 'Sortparm' which is used to force the
"all" row to the top of the list.

SELECT Customers.CustomerID,
Customers.CompanyName,
2 as sortparm
FROM Customers
Union select
"0" as Customerid,
"<All Customers>" as CompanyName,
1 as sortparm
from Customers
ORDER BY
sortparm,
Customers.CompanyName;

Note that to create a union query you must use SQL view of query design.
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a combo box( cmbCustomerCode) which is suppossed to
show all the names of a customers.
But now, I would like to have the first row of the
combobox to be 'All'.
I do not want to manually type all the customers' names
and insert them as a value list of the combobox as it
would not be dynamic that way. (New customers added into
the database would not show up in the combobox)

Should i try AddItem()?or is there other ways to do it?

Thanx for your help...

Ling

.
 
Back
Top