This is my code below at the bottom of this post; 4 hours of headbanging and I cannot figure it out. I have one source table and one target table. Three fields in the sub query are to be used to filter the resulting recordset.
The source table contains some records already in the target table, so I do not want to process those records.
I only want to process records in source table ES003CBP that are not in target table ES003EIN
The problem I discovered by using the QBE to debug my code is that the fields in the subquery (in bold below) are expecting a parameter to be passed to them so the query will run, but I want all missing records in the target table resident in the source table, not records that are the result of a parm that I pass to the query. Because these query fields are not populated with the parm the subquery is expecting, I get the 3061 error.
Once I obtain the result set of records in the source table not being present in the target table, I want to manipulate data and then write the new record into the target table. Intresting side note, I have three fields used to join the two tables together but the 3061 error says 2.
Source table: ES003CBP
Target table: ES003EIN
Fields expecting values as passed parms:
[ES003CBP].[ENTRYSUMMARYLINE
[ES003EIN].[ENTRYSUMMARYLINE]
[ES003CBP].[ENTRYSUMMARYLINENUMBER]
[ES003EIN].[ENTRYSUMMARYLINENUMBER]
[ES003CBP].[TARIFFORDINALNUMBER]
[ES003EIN].[TARIFFORDINALNUMBER]
Do I need to somehow force these values so they are not expected to be parms, but are criteria necessary to return only records from the source table?
Set rstsrc = db.OpenRecordset("SELECT * FROM ES003CBP WHERE NOT EXISTS " & _
(SELECT * FROM ES003EIN WHERE ([ES003CBP].[ENTRYSUMMARYLINE] = [ES003EIN].[ENTRYSUMMARYLINE]) " & _
AND " & _
"([ES003CBP].[ENTRYSUMMARYLINENUMBER] = [ES003EIN].[ENTRYSUMMARYLINENUMBER]) AND " & _
"([ES003CBP].[TARIFFORDINALNUMBER] = [ES003EIN].[TARIFFORDINALNUMBER])) " & _
"ORDER BY ENTRYSUMMARYNUMBER, ENTRYSUMMARYLINENUMBER, TARIFFORDINALNUMBER")"
The source table contains some records already in the target table, so I do not want to process those records.
I only want to process records in source table ES003CBP that are not in target table ES003EIN
The problem I discovered by using the QBE to debug my code is that the fields in the subquery (in bold below) are expecting a parameter to be passed to them so the query will run, but I want all missing records in the target table resident in the source table, not records that are the result of a parm that I pass to the query. Because these query fields are not populated with the parm the subquery is expecting, I get the 3061 error.
Once I obtain the result set of records in the source table not being present in the target table, I want to manipulate data and then write the new record into the target table. Intresting side note, I have three fields used to join the two tables together but the 3061 error says 2.
Source table: ES003CBP
Target table: ES003EIN
Fields expecting values as passed parms:
[ES003CBP].[ENTRYSUMMARYLINE
[ES003EIN].[ENTRYSUMMARYLINE]
[ES003CBP].[ENTRYSUMMARYLINENUMBER]
[ES003EIN].[ENTRYSUMMARYLINENUMBER]
[ES003CBP].[TARIFFORDINALNUMBER]
[ES003EIN].[TARIFFORDINALNUMBER]
Do I need to somehow force these values so they are not expected to be parms, but are criteria necessary to return only records from the source table?
Set rstsrc = db.OpenRecordset("SELECT * FROM ES003CBP WHERE NOT EXISTS " & _
(SELECT * FROM ES003EIN WHERE ([ES003CBP].[ENTRYSUMMARYLINE] = [ES003EIN].[ENTRYSUMMARYLINE]) " & _
AND " & _
"([ES003CBP].[ENTRYSUMMARYLINENUMBER] = [ES003EIN].[ENTRYSUMMARYLINENUMBER]) AND " & _
"([ES003CBP].[TARIFFORDINALNUMBER] = [ES003EIN].[TARIFFORDINALNUMBER])) " & _
"ORDER BY ENTRYSUMMARYNUMBER, ENTRYSUMMARYLINENUMBER, TARIFFORDINALNUMBER")"