views:

362

answers:

4
+1  Q: 

VBA update query

Below query is resulting zero rows updated

but i am sure that there is a record to update

DoCmd.RunSQL (" Update tbltesting set IsDiff ='Yes' " & _
                "where empid= " & Me.txtEmpId.Value & _
                " and testid= " & Me.txtAutoNumber.Value & ";")

Please help!!

A: 

Maybe you need single quotes around the WHERE parameters:

DoCmd.RunSQL (" Update tbltesting set IsDiff ='Yes' where empid= '" & Me.txtEmpId.Value & "' and testid= '" & Me.txtAutoNumber.Value & "';")
Matthew Jones
No, we've already covered this in the OPs original thread. :(
David Walker
A: 

Try removing .Value and ; If it still not updating then change 'Yes' to 1.

You can also try Yes without single quotes.

THEn
The value of True in Access and Jet/ACE is -1, not 1. However, using 1 here actually does work when appending to a Boolean field, because True (-1) is really defined as Not False. I would use True without quotes if I were writing this SQL.
David-W-Fenton
"Boolean field" -- oxymoron. SQL data types can be NULL and the Access database engine's YESNO data type is no exception. Three value logic does not equal Boolean.
onedaywhen
A: 

In debug mode cut and paste the delete statement with the actual values into whatever database development environment you are using - run the query in the data base this will tell you if there is a syntax problem or data problem

LJF
+1  A: 

Run this as a check to make sure your fields have the data that you think they have:

DoCmd.RunSQL (" SELECT * FROM tbltesting " & _
                "WHERE empid= " & Me.txtEmpId.Value & _
                " and testid= " & Me.txtAutoNumber.Value & ";")

Incidentally, you can leave off the .Value portion.

David Walker
hahhahaha there was no data sorry for the trouble :-)
No problem. Glad you got it straightened out.
David Walker