Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2009, 05:31 PM
Authorized User
 
Join Date: Jan 2009
Posts: 14
Thanks: 4
Thanked 0 Times in 0 Posts
Question Combo Box Drop List Including Multiple Fields

I have a single table database that includes the following fields: Supplier1, Supplier2, Supplier3. On my form I placed three combo boxes, cboSupplier1, cboSupplier2, cboSupplier3, each bound to one of these fields. When I drop down the list for any of these combo boxes I want to see all of the values stored in the three fields.
In other words if
Supplier1 contains Wendy's, McDonalds, Taco Bell
Supplier2 contains Sears, Best Buy, Target
Supplier3 contains Joe, Bill, Bob
I want each of the three combo box drop lists to include Wendy.s, McDonalds, Taco Bell, Sears, Best Buy, Target, Joe, Bill, Bob
I tried the following SELECT statement but it only lists values from Supplier1, not from Supplier2 or Supplier3.
SELECT DISTINCT tblShopProjects.Supplier1, tblShopProjects.Supplier2, tblShopProjects.Supplier3 FROM tblShopProjects;
I am just a VBA beginner and this has me stumped. Any help would be appreciated. Thank You.
 
Old May 1st, 2009, 08:10 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The way you're selecting you'll get 3 columns of data but all on the same row for the dropdown. In order to make them all options in your dropdown, the query syntax would be something like:
Select Distinct Supplier1 From tblShopProjects Union Select Supplier2 From tblShopProjects Union Select Supplier3 From tblShopProjects

Hope this helps.
The Following User Says Thank You to allenm For This Useful Post:
RodM (May 2nd, 2009)
 
Old May 2nd, 2009, 06:59 AM
Authorized User
 
Join Date: Jan 2009
Posts: 14
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Thank you, allenm, the union query you suggested worked perfectly. My combo boxes now list every distinct item from each of my fields just as I wanted. Thanks for teaching me somthing new as I am just a novice.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Won't Drop Down sjf905 C# 0 January 13th, 2007 12:09 AM
having some fields of a grid view a drop list dsblack@montgomerycountyt ASP.NET 2.0 Professional 0 June 2nd, 2006 04:18 PM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.