I have an Access VBA routine that uses a query with one of the criteria being a batch number from a form. The routine worked for a week and then gave me a -2147217904 No value given for one or more required parameters error message. After a great deal
of testing I took the table, and created a new query and form in a blank db and it all worked for a few days and then gave me the same error. I've take the query and written an SQL statement with the same result. I created a new batch field in my table that
is a text (string) instead of a long integer and it works.
Here is the SQL statement:
rst_Box.Open "SELECT Prod_Batch_Nbr, CustNum, PartNum, cpt_Crate, cpt_Box, cpt_OW, cpt_IH, cpt_Total_Order_Qty, cpt_Total_Ship_To_Qty" _
& " FROM tbl_Production_Sched_Shutters" _
& " WHERE [Prod_Batch_Nbr] = Forms!frm_D075_ShutterSelection.[cpt_Batch_Nbr] AND ([PartNum] = '" & str_Part1 & "' Or PartNum = '" & str_Part2 & "'Or PartNum = '" & str_Part3 & "');", _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Here is the SQL statement with the batch number as a string:
rst_Box.Open "SELECT Prod_Batch_Nbr_String, CustNum, PartNum, cpt_Crate, cpt_Box, cpt_OW, cpt_IH, cpt_Total_Order_Qty, cpt_Total_Ship_To_Qty" _
& " FROM tbl_Production_Sched_Shutters" _
& " WHERE (([Prod_Batch_Nbr_String] = '" & Forms!frm_D075_ShutterSelection.[cpt_Batch_Nbr_String] & "') AND ([PartNum] = '" & str_Part1 & "' Or PartNum = '" & str_Part2 & "'Or PartNum = '" & str_Part3 & "'));", _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic