Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Update Query

Status
Not open for further replies.

illini

Technical User
Aug 2, 2002
89
FR
I have an update query as follows:

RecID=LB_Search_Company.Column(0)

DoCmd.RunSQL "UPDATE Tbl_OCN SET Tbl_Company.Client = ""-1"" WHERE ((([Tbl_Company].[ClientID])= " & RecID & "));"


This gives me a Runtime Error '3464' ("Data type mismatch in criteria expression").

However, the query runs fine if I replace the RecID with the actually number:

DoCmd.RunSQL "UPDATE Tbl_OCN SET Tbl_Company.Client = ""-1"" WHERE ((([Tbl_Company].[ClientID])= ""1233""));"

Where is my original query going wrong? -illini
 
It looks like the 1223 is surrounded by quotes, while RecID isn't.

To make the two similar, you would use:
WHERE ((([Tbl_Company].[ClientID])= """ & RecID & """));"


Alternately, you can use single quotes to quote a string:
WHERE ((([Tbl_Company].[ClientID])= "' & RecID & '"));"
 
Thank-you. The first worked great! -illini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top