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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fill combo box with data from two tables

Status
Not open for further replies.

dominicg123

Technical User
Jan 5, 2007
23
CA
I have a combo box on a form called cboreference. I want to fill the combo box with data from two tables: customer and user. Is this suppose to be done with VBA?
 
Use the help file look for "UNION" query

Creates a union query , which combines the results of two or more independent queries or tables.

Syntax
query1 UNION [ALL]
query2 [UNION [ALL]
queryn [ ... ]]

The Northwind sample database has an example which is simliar combining suppliers and customers.
 
How are ya dominicg123 . . .

My first instinct is to prompt you to have a look at [blue]union queries[/blue]. Question is . . . [blue]how are you intending to display/format the data in the combobox?[/blue]

BTW: [blue]Welcome to Tek-Tips![/blue] To get great answers and know whats expected of you in the forums be sure to have a look at FAQ219-2884 [thumbsup2]

Calvin.gif
See Ya! . . . . . .
 
dominicg123 . . .

In the query pane its the one with the two rings . . .

Calvin.gif
See Ya! . . . . . .
 
Thank you all this is my result

SELECT qryContacts.[No De Contact], qryContacts.[Contact(Nom/Prénom)]
FROM qryContacts
ORDER BY qryContacts.[No De Contact]

UNION ALL


SELECT Users.UserID, " " AS Expr1
FROM Users
 
There is a query called "Customers Suppliers by City"

SELECT City, CompanyName, ContactName, "Customers" AS [Relationship]
FROM Customers
UNION SELECT City, CompanyName, ContactName, "Suppliers"
FROM Suppliers
ORDER BY City, CompanyName;

Not sure where they use it, but it could be a recordsource for a combo box if you wanted it to be. Pretty similiar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top