I created a query in the Access Query Builder that I modified to use with VBA Code so I could reuse it for any record I choose. The one that I created with the Access Query builder works beautifully with the hardcoded criteria. The VBA version with my criteria being set by a variable returns Error 3021.
I am using a DAO Recordset and all I want to do is retrieve the data to place into a report.
The Original made in the Access Query Builder:
The modified version for VBA:
Any ideas? Thanks in advance.
Steve
I am using a DAO Recordset and all I want to do is retrieve the data to place into a report.
The Original made in the Access Query Builder:
Code:
SELECT * FROM (((tbl_Reject INNER JOIN tbl_Serial_Number ON tbl_Reject.[Reject_Number(PK)] = tbl_Serial_Number.[Reject_number(FK)]) INNER JOIN tbl_Approvals ON tbl_Reject.[Reject_Number(PK)] = tbl_Approvals.[Reject_Number(FK)]) INNER JOIN tbl_Expeditor_Defect_Type ON tbl_Reject.[Reject_Number(PK)] = tbl_Expeditor_Defect_Type.[Reject_number(FK)]) INNER JOIN tbl_Inventory_Reason_Code ON tbl_Reject.[Reject_Number(PK)] = tbl_Inventory_Reason_Code.[Reject_number(FK)] WHERE (((tbl_Reject.[Reject_Number(PK)])=250189));
Code:
strSQL_Edit_Record = "SELECT * FROM (((tbl_Reject INNER JOIN tbl_Serial_Number ON tbl_Reject.[Reject_Number(PK)] = tbl_Serial_Number.[Reject_number(FK)])" & _ " INNER JOIN tbl_Approvals ON tbl_Reject.[Reject_Number(PK)] = tbl_Approvals.[Reject_Number(FK)])" & _ " INNER JOIN tbl_Expeditor_Defect_Type ON tbl_Reject.[Reject_Number(PK)] = tbl_Expeditor_Defect_Type.[Reject_number(FK)])" & _ " INNER JOIN tbl_Inventory_Reason_Code ON tbl_Reject.[Reject_Number(PK)] = tbl_Inventory_Reason_Code.[Reject_number(FK)]" & _ " WHERE (((tbl_Reject.[Reject_Number(PK)])=" & lngEditCriteria & "));"
Steve
Comment