Help with queries

ciwilliams1983
09-11-2000, 04:59 PM
Hi,

I need to be able to search through records in a table for a specific value using SQL, then display all the information for the records on screen, giving the option to print it. The part which I don't know to start is how to also bring in all the records from another table which have the first table's ID as a reference. I created both tables in Access. I expect there to be a very feasible potential for there to be lot of information on screen, whilst it being equally possible that there is only one record from table 2 which has the referenced ID from the record in table 1. I hope I've explained this clearly enough. Then again, I probably haven't, but you guys are pretty smart, so I guess you'll know what I'm bantering on about.... I hope :-) If anyone could offer any help on this, I'd be very grateful.

Thank you for all your help,
Chris Williams.

BillSoo
09-12-2000, 12:42 PM
Try:

sql$ = "SELECT * FROM table2 WHERE foreignkey = " & table1!MyKey

Where table1 and table2 are your tables, MyKey is table1 ID and foreignkey is the field in table 2 where table1s ID is stored.



"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Valkyrie
09-12-2000, 12:44 PM
You will need to join the two tables. If you are using MS Access you can use the Query builder to create a query and test it. Once you are satisfied with it you can copy it into your pgm.

HTH


Quote of the moment....
"My job is so top secret even I don't know what I'm doing!"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum