G
Garry
I am trying to run an SQL statement in VBA. I created an update query,
changed to SQL view and copied the SQL to the code. The relevant portions of
the code follow
_____________________________________________________________________
Dim strSQL As String
Dim strItemNo As String
strItemNo =recDefect(“Item_Noâ€)
strSQL = "UPDATE tblProduct_List " _
& "SET tblProduct_List.Qty_On_Hand = [tblProduct_List]![Qty_On_Hand] + 1 " _
& " WHERE (((tblProduct_List.Item_No)= " & strItemNo & "));"
DoCmd.RunSQL strSQL
_________________________________________________________________________
tblProductList fields:
Qty_On_Hand is an integer
Item_No is a text field of length 10, and is the primary key
recDefect is a recordset based on a table, and Item_No is a text field of
length 10.
The only change I made is to the criteria, it was a parameter in the query
so I changed “parm1†to the variable strItemNo and adjusted the quotes in the
WHERE part.
No matter what I try, I get error 3464, data type mismatch in criteria
section.
I tried several modifications including changing …& strItemNo &
TO …& recDefect(“Item_Noâ€) &
and TO …& “99994†& -- (99994 is an Item_No in tblProductsList)
I keep getting the type mismatch error when the code executes and Debug
points to the DoCmd.RunSQL statement – no help at all.
I am running Access 2000 and using DAO and fairly new to Access and SQL is a
foreign language.
Any suggestions would be greatly appreciated.
Thanks in advance -- Garry Gross
changed to SQL view and copied the SQL to the code. The relevant portions of
the code follow
_____________________________________________________________________
Dim strSQL As String
Dim strItemNo As String
strItemNo =recDefect(“Item_Noâ€)
strSQL = "UPDATE tblProduct_List " _
& "SET tblProduct_List.Qty_On_Hand = [tblProduct_List]![Qty_On_Hand] + 1 " _
& " WHERE (((tblProduct_List.Item_No)= " & strItemNo & "));"
DoCmd.RunSQL strSQL
_________________________________________________________________________
tblProductList fields:
Qty_On_Hand is an integer
Item_No is a text field of length 10, and is the primary key
recDefect is a recordset based on a table, and Item_No is a text field of
length 10.
The only change I made is to the criteria, it was a parameter in the query
so I changed “parm1†to the variable strItemNo and adjusted the quotes in the
WHERE part.
No matter what I try, I get error 3464, data type mismatch in criteria
section.
I tried several modifications including changing …& strItemNo &
TO …& recDefect(“Item_Noâ€) &
and TO …& “99994†& -- (99994 is an Item_No in tblProductsList)
I keep getting the type mismatch error when the code executes and Debug
points to the DoCmd.RunSQL statement – no help at all.
I am running Access 2000 and using DAO and fairly new to Access and SQL is a
foreign language.
Any suggestions would be greatly appreciated.
Thanks in advance -- Garry Gross