Hi,
I'm trying to execute an update query thru code. When I do it manually it works OK, but when it does it thru code I get an error which says the query is missing 2 parameters. I am taking to values from a form. They are instantiated in the query but for some reason the 2 parameters do not get passed when running the query using code.
Here's my code:
Here's is my SQL string generated by ACCESS:
I also tried doing the following but wasn't successful:
I appreciate any help provided.
I'm trying to execute an update query thru code. When I do it manually it works OK, but when it does it thru code I get an error which says the query is missing 2 parameters. I am taking to values from a form. They are instantiated in the query but for some reason the 2 parameters do not get passed when running the query using code.
Here's my code:
Code:
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set myQuery = mydb.QueryDefs("Q_WHSEDIST REQUEST 10")
mydb.Execute (myQuery.Name)
myQuery.Close
Code:
SELECT [Q_RETURN REQUEST LETTER].VNDRCODE, [Q_RETURN REQUEST LETTER].SF, [Q_RETURN REQUEST LETTER].SUPPLIER, [Q_RETURN REQUEST LETTER].[SURPLUS ADDRESS], [Q_RETURN REQUEST LETTER].ADDRESS4, [Q_RETURN REQUEST LETTER].PHONE, [Q_RETURN REQUEST LETTER].FAX, [Q_RETURN REQUEST LETTER].ATTN, [Q_RETURN REQUEST LETTER].DEAR INTO T_WHSE2
FROM [Q_RETURN REQUEST LETTER]
WHERE ((([Q_RETURN REQUEST LETTER].VNDRCODE)=[Forms]![F_VENDOR RETURN REQUESTS]![txtVendorID]) AND (([Q_RETURN REQUEST LETTER].SF)=IIf([Forms]![F_VENDOR RETURN REQUESTS]![txtVendorSF]="0"," ",[Forms]![F_VENDOR RETURN REQUESTS]![txtVendorSF])));
Code:
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set myQuery = mydb.QueryDefs("Q_WHSEDIST REQUEST 10")
[b]myQuery.Parameters(0).Value = CStr([Forms]![F_VENDOR RETURN REQUESTS]![txtVendorID])
myQuery.Parameters(1).Value = CStr([Forms]![F_VENDOR RETURN REQUESTS]![txtVendorSF])[/b]
mydb.Execute (myQuery.Name)
myQuery.Close
I appreciate any help provided.