Re: Access 2003/Oracle 9i
I have an Access app that connects to an Oracle DB via OLEDB/VBA code
(no DSN or ODBC)
Queries against straight Oracle tables run fine.
For this query, however, the condition for finding DeptID's in the
Oracle table have to be filtered by a list of DeptID's found in
"tblDeptID" which is a simple local Access table containing one column
called "DeptID". There are 383 rows in this local table.
This code runs except for when I try and reference my local table.
Here is the code:
<begin code>
dim APVdb as Database
Set APVdb as CurrentDB()
strSQL = "SELECT A.MATCH_RULE_ID , " & _
"Count(A.MATCH_ RULE_ID) As CountofMATCH_RU LE_ID " & _
"FROM " &_
"PS_VCHR_MTCH_E XCPT A, " & _
"PS_VOUCHER_LIN E B " & _
"WHERE " & _
"A.BUSINESS_UNI T = B.BUSINESS_UNIT " & _
"AND A.VOUCHER_ID = B.VOUCHER_ID " & _
"AND A.VOUCHER_LINE_ NUM = B.VOUCHER_LINE_ NUM " & _
"AND A.PO_ID IN "
strSQL = strSQL & "(SELECT DISTINCT A.PO_ID " & _
"FROM PS_PO_LINE_DIST RIB A " & _
"WHERE A.DEPTID IN " & _
"(SELECT DEPTID from " & APVdb.tblDeptID & ")) " & _
"GROUP BY A.MATCH_RULE_ID "
<end code
Notice the next to the last line references my local table "tblDeptID" .
I have tried
- Currentdb.tblDe ptID
- dbo.tblDeptID
- Me.CurrentDB(Tb lDeptID)
- tblDeptID
...all to no avail.
I tried a pass-through query, but that does not work.
If you have an example where you are using a local lookup table of
values as a conditional select against an Oracle database, I would be
interested to see how it is done.
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***