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

Search multiple tables 1

Status
Not open for further replies.

dmoran

Technical User
Feb 12, 2004
13
US
I have a co-worker who wants to query two tables using a unique control number as criteria. These tables are identical(one is an archive)in structure and have thousands of records each. Could someone please help me with a way to search both tables for a record?

Thanks,
David
 
Open them one at a time and search them with vb.


rollie@bwsys.net
 
Apply your WHERE criterion to a UNION query.

Create the query for the first table in the Query Screen. Switch to SQL view and cut/paste the SQL with UNION in between the two selects. Amend the fieldnames where necessary. Now name and run the query in the normal way.

 
Thanks for the replies -
I was successful with union query but am still unsure about the "Where" clause for this. Ultimately, I would like to enter the "control number" on a form which then populates the form with the selected record. I understand the "Where" when you have a defined criteria, but haven't grasped how to enter the criteria once for both tables. Hope that's no too confusing-
David
 
Just for starters, if you use something like this:


WHERE (((TABNAME.ControlID)=[Enter Control ID]));

The form will put up a dialogue box and then display just the appropriate records.

 
Thanks a lot for the help - that did it. Also, I just added a union statement to a combo-box that got the same results - although it takes a second to load the combo box if you have a lot of records.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top