Jaison
Jaison

Reputation:

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!!

Upvotes: 1

Views: 2068

Answers (4)

David Walker
David Walker

Reputation: 1506

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.

Upvotes: 1

LJF
LJF

Reputation:

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

Upvotes: 0

THEn
THEn

Reputation: 1938

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

You can also try Yes without single quotes.

Upvotes: 0

Matthew Jones
Matthew Jones

Reputation: 26190

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 & "';")

Upvotes: 0

Related Questions