UPDATE QUERY (1 Viewer)

sbaud2003

Member
Local time
Today, 17:41
Joined
Apr 5, 2020
Messages
178
My qudate query is not running showing error : key violation. Although when i tries to run the query directly is doesnot show any error and it is updating the records. But when i am trying to run it from the form, due to LOCK violation table not updated.

my SQL is

UPDATE MEMBERS SET MEMBERS.EL = [EL]-[FORMS]![LEAVE_UPDATE]![TXTNOD]
WHERE (((MEMBERS.ACCOUNT_NO)=[FORMS]![LEAVE_UPDATE]![TXTAC]) AND (([FORMS]![LEAVE_UPDATE]![LEAVE_TYPE])="EL"));
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 05:11
Joined
Oct 29, 2018
Messages
21,473
How exactly are you trying to run the query from a form? Can you show us your code?
 

sbaud2003

Member
Local time
Today, 17:41
Joined
Apr 5, 2020
Messages
178
How exactly are you trying to run the query from a form? Can you show us your code?
I am using a command button and in the click event i have the followind code:

DoCmd.SetWarnings False
DoCmd.OpenQuery "QUPDATE_ELR"
DoCmd.SetWarnings True


QUPDATE_ELR is the query SQL is
UPDATE MEMBERS SET MEMBERS.EL = [EL]-[FORMS]![LEAVE_UPDATE]![TXTNOD]
WHERE (((MEMBERS.ACCOUNT_NO)=[FORMS]![LEAVE_UPDATE]![TXTAC]) AND (([FORMS]![LEAVE_UPDATE]![LEAVE_TYPE])="EL"));
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:11
Joined
Oct 29, 2018
Messages
21,473
Is your form bound to the Members table? If so, try saving any recod changes first before running the query.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:11
Joined
Feb 19, 2002
Messages
43,275
Also, make sure the default lock setting is "no Locks"
1696979614529.png
 

Users who are viewing this thread

Top Bottom