Connecting Tech Pros Worldwide Forums | Help | Site Map

How do I add one list to another list in Access?

Newbie
 
Join Date: Oct 2009
Posts: 4
#1: Oct 2 '09
I have a TO_EQP field and a FROM_EQP field. I want to make a combo box that displays both fields in a single column but removes duplicate entries. I figured I might have to somehow add one list to the bottom of the other and then remove the duplicate entries. I'm new at this and any help would be appreciated.

Member
 
Join Date: Jul 2009
Posts: 41
#2: Oct 2 '09

re: How do I add one list to another list in Access?


Duplicate entries such as duplicates within the TO/FROM fields or where TO and FROM are the same? Or both?
Member
 
Join Date: Jul 2009
Posts: 41
#3: Oct 2 '09

re: How do I add one list to another list in Access?


First append your field:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO Table (TO_EQP)
  2. SELECT DISTINCT FROM_EQP
  3. FROM Table;
  4.  
Then you can do something like:
Expand|Select|Wrap|Line Numbers
  1. Dim sqlstr as String
  2. sqlstr = "SELECT DISTINCT TO_EQP FROM Query"
  3. ComboBox.ControlSource = sqlstr
  4.  
I'm pretty new too, but I think that's something close to what you're looking for
Newbie
 
Join Date: Oct 2009
Posts: 4
#4: Oct 2 '09

re: How do I add one list to another list in Access?


Thanks! I think we're going in the same direction but is there any way to do this is a query form without having to alter the tables ... maybe this will help describe what I'm looking for

TO_EQP
EQP_A
EQP_B
EQP_C

FR_EQP
EQP_1
EQP_2
EQP_3

And what I'm looking for is this

FR_TO_EQP
EQP_A
EQP_B
EQP_C
EQP_1
EQP_2
EQP_3
Newbie
 
Join Date: Oct 2009
Location: Finger Lakes
Posts: 4
#5: Oct 2 '09

re: How do I add one list to another list in Access?


SELECT Table1.[fr_EQP] AS FR_TO_EQP
FROM Table1
Union SELECT Table1.TO_EQP AS FR_TO_EQP
FROM Table1;

Here is and sql string that will give you the list.
Newbie
 
Join Date: Oct 2009
Posts: 4
#6: Oct 5 '09

re: How do I add one list to another list in Access?


Perfect, exactly what I was looking for.
One more question though, is it possible to add some additional criteria to limit what is outputted in the query? If I have locations for each piece of equipment from the same table is it possible to only output the equipment from a specific location. I know how to do it in the design view (using criteria) but I can only seem to open up the SQL code for the union.
Newbie
 
Join Date: Oct 2009
Location: Finger Lakes
Posts: 4
#7: Oct 5 '09

re: How do I add one list to another list in Access?


Do each part of the union in a seperate query in design view using criteria. Copy the sql string from one query and append it to the other query. And replace the ending semicolon of the first query string with union.
Newbie
 
Join Date: Oct 2009
Posts: 4
#8: Oct 6 '09

re: How do I add one list to another list in Access?


I finally have it working.
I added another query which involved the union and put my restraints in the criteria field.
Thanks everyone, much appreciated.
Reply