PDA

View Full Version : Combo - SQL recordsource - Add Blank option



Movian
03-28-2012, 12:29 PM
Hey,
i have a combo box that is going to be populated by a SQL recordsource "Selete calname from tblCalendar ORDER BY Calname"

But i also want to have an Blank option as well as the list the SQL generates. This is going to be used for filtering a listbox, show all the records if its blank and if not show them where it matches...

Any ideas how i may go about doing that?

hansup
03-29-2012, 08:33 AM
Change the combo's row source to a UNION query.

SELECT "** ALL **" AS calname FROM Dual
UNION ALL
SELECT calname FROM tblCalendar
ORDER BY Calname

Dual is a table which contains a single row. But you can substitute any data source which returns one row.

That approach will add the option to the combo. However I'm unsure how you are using the combo selection to filter the list box row source. Something like this could work.

PARAMETERS Forms!YourForm!YourCombo TEXT(255);
SELECT display_field FROM some_table
WHERE
Forms!YourForm!YourCombo = "** ALL **"
OR selector_field = Forms!YourForm!YourCombo;

Or you could rewrite the list box's row source from the combo's after update event.