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

vba sql client access join examples

Status
Not open for further replies.
Sep 5, 2003
87
US
**** Cross-post from VBA Visual Basic for Applications. I thought it might be relavant here also. ****

Thanks

I am trying to build a multi table join sql statement using Excel VBA thru client access for an AS400 DB2 database.

I do single tables all the time. I would love to move on to multi table queries. Here is what I have so far. Any ideas or examples would be helpful

sqlstr = "SELECT T1.PSSVCTYP, T1.PSSVCID, T2.SVACCT, T2.SVBRCH, T3.AMNAME, T1.PSPCOD, T4.PMDESC, T4.PMTHDT, T4.PMCYCLES, T1.PSCYCLES"
sqlstr = sqlstr & " FROM " & CurrLib & ".SVCWIL/PROSVCID, SVCWIL/SRVMAST99, SVCWIL/ACTMAST, SVCWIL/PROMSTR"
sqlstr = sqlstr & " WHERE T1.PSSVCID = T2.SVCID AND T2.SVACCT = T3.AMACCT AND T2.SVBRCH = T3.AMBRCH AND T1.PSPCOD = T4.PMPCOD"
sqlstr = sqlstr & " Order by T1.PSSVCID"

Thanks
 
You might want to post that here forum192, as this is the MS SQL Programming forum.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Hi mikej,

You probably didn't know that cross-posting is frowned on in the tek-tips forums. But, now you do know!

-------------------------------------
A sacrifice is harder when no one knows you've made it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top