Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use UNION statement in SQL to create a dummy record.

Access Howto:

Use UNION statement in SQL to create a dummy record.

by  Klopper  Posted    (Edited  )
Picture this:
A combo box on a form has an SQL statement for a row source:
Eg. "SELECT DISTINCT City FROM tblCustomer"

This obviously populates the combo box with a unique list of all the cities in the tblCustomer table. Lets say the the users makes a selection from the combo box to run a sales report by city - by using the SELECT DISTINCT statement as a row source, the combo box will always show all the cities in the table.

To provide the user with an option to run the sales report for ALL cities, use the UNION statement to create a dummy record:
Eg. "SELECT DISTINCT City FROM tblCustomer UNION SELECT 'ALL' AS City FROM tblCustomer"


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top