Combo box or *

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

I've got a combo box that lists countries; select a
country and the sub form of related info updates to show
records filterd by that country.

The combo box has an SQL statment something like
SELECT CountryID, Country_Name FROM country

Gives all the countries in the list.


Question: How can I add '*' (all) tot he combo, so the
records are shown for all countries? ie you can have
records filterd by country, or you can have the recrds
for all countries?

TIA
Tim
 
Tim,

To add the * option to the combo, change its rowsource SQL statement to:

SELECT CountryID, Country_Name FROM country
UNION SELECT "*","All Countries" FROM country

Then, in the subform RecordSource SQL change the WHRE clause from:
WHERE CountryID = ' " & cboCountryID & " ' "
to
WHERE CountryID Like ' " & cboCountryID & " ' "

i.e. change the = to Like, so * returns all.

HTH,
Nikos
 
Nicely done!
Cheers Nik

-----Original Message-----
Tim,

To add the * option to the combo, change its rowsource SQL statement to:

SELECT CountryID, Country_Name FROM country
UNION SELECT "*","All Countries" FROM country

Then, in the subform RecordSource SQL change the WHRE clause from:
WHERE CountryID = ' " & cboCountryID & " ' "
to
WHERE CountryID Like ' " & cboCountryID & " ' "

i.e. change the = to Like, so * returns all.

HTH,
Nikos




.
 
Back
Top