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

SQL query question VB6

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi all

Quick question to see if it can be done. When using acces it is possible to build a query and then use this query in the query builder when creating a second query.

What i want to know is that if it is possible to write a sql query as a string in VB but use a recordset which is populated in code to join on.

i.e.
This is an example in access

Code:
SELECT CONTACTS.*
FROM CONTACTS INNER JOIN [chdis 1] ON CONTACTS.PATIENT_NO = [chdis 1].PATIENT_NO;

i'd like a similar sort of thing using a recordset and have tried something like this to no avail.

Code:
SELECT CONTACTS.* FROM CONTACTS INNER JOIN [" & rsChildDischarges & "] ON CONTACTS.PATIENT_NO = [" & rsChildDischarges & "].PATIENT_NO

where rsChildDischarges is a recordset.

Any help on this matter would be most appreciated.

Thanks in advance.
 
You could do it all in one SQL. Don't know if that would help?

SELECT CONTACTS.* FROM CONTACTS INNER JOIN [chdis 1] ON CONTACTS.PATIENT_NO IN ("First SQL that got you rsChildDischarges")



Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top