benkingery
Registered User.
- Local time
- Today, 16:20
- Joined
- Jul 15, 2008
- Messages
- 153
I'm importing orders into a temporary table. There are two types of records that will be imported. 1) Header records (IH), 2) Detail records (ID). As soon as the records are into the temporary table, I am appending the Header records to the header table, and the detail records to the detail table.
Here's the problem. The source data file looks like this:
IH|AF245975|2006-06-05|Adam Reczkowski|3 Berk St||Boston|MA|02199|US|617-555-5552
ID|4056|4|55.50|Floor Lamp|Ground|Test Comment
ID|BC456|1|17.75|Hall Lamp|Ground|Test Comment 2
You can see that there is no foreign key reference on the detail records to tie them to he header record. This is a problem, because in their normalized tables, the detail table has a foreign key reference to the header record value in the second column ("AF245975" in this instance).
Each file that I import will have only 1 header record and the detail records that go with it, so there's no possibility of mixing up header and detail records. The append query to the header table works fine, but the append query to the child table is giving me problems when put into a VBA module. If I try just the SQL for the Detail append query, I have NO problems. Its only when the SQL is run from VBA that there is a problem. I suspect it has something to do with the ' and " around Expr 1.
Can anyone offer some syntax help here? I think thats the problem.
FYI, the error I'm gettng reads: "Run-tim error '3075': Syntax error (Missing operator) in query expression 'DLookUp('[CSNOB_02]','ORDERS_CSN_OrderBuffer','[CSNOB_01]='IH''
Here's the problem. The source data file looks like this:
IH|AF245975|2006-06-05|Adam Reczkowski|3 Berk St||Boston|MA|02199|US|617-555-5552
ID|4056|4|55.50|Floor Lamp|Ground|Test Comment
ID|BC456|1|17.75|Hall Lamp|Ground|Test Comment 2
You can see that there is no foreign key reference on the detail records to tie them to he header record. This is a problem, because in their normalized tables, the detail table has a foreign key reference to the header record value in the second column ("AF245975" in this instance).
Each file that I import will have only 1 header record and the detail records that go with it, so there's no possibility of mixing up header and detail records. The append query to the header table works fine, but the append query to the child table is giving me problems when put into a VBA module. If I try just the SQL for the Detail append query, I have NO problems. Its only when the SQL is run from VBA that there is a problem. I suspect it has something to do with the ' and " around Expr 1.
Can anyone offer some syntax help here? I think thats the problem.
Code:
ApdCSN_OrderDetail = "INSERT INTO ORDERS_CSN_OrderDetail ( Record_Identifier, Item_Number, Quantity, Wholesale_Price, Item_Description, Ship_Method, Custom_Comments, PO_Number )"
ApdCSN_OrderDetail = ApdCSN_OrderDetail + " SELECT ORDERS_CSN_OrderBuffer.CSNOB_01, ORDERS_CSN_OrderBuffer.CSNOB_02, ORDERS_CSN_OrderBuffer.CSNOB_03, ORDERS_CSN_OrderBuffer.CSNOB_04, ORDERS_CSN_OrderBuffer.CSNOB_05, ORDERS_CSN_OrderBuffer.CSNOB_06, ORDERS_CSN_OrderBuffer.CSNOB_07, DLookUp('[CSNOB_02]','ORDERS_CSN_OrderBuffer','[CSNOB_01]='IH'') AS Expr1"
ApdCSN_OrderDetail = ApdCSN_OrderDetail + " FROM ORDERS_CSN_OrderBuffer WHERE (((ORDERS_CSN_OrderBuffer.CSNOB_01)='ID'))"