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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key Violation

Status
Not open for further replies.

jammerdk

Technical User
Aug 16, 2001
51
DK
I'm having trouble by solving a Key Violation when running a Append query.

The Query works fine when ever all the records in the table are removed but whenever any AttMed records in the table "Attend" I get the message of a KeyViolation but the query still Append the records I want it to but I still love for the Key Violation not to appear.

:eek:)

strSQL = "INSERT INTO Attend ( AttMed, AttTeam, AttDate, AttMeetTime, AttType )" _
& " SELECT Query3.MedID, Query3.TeamNo, Forms!frmHovedmenu!txtToday, Query3.MeetTime, 1" _
& " FROM Query3" _
& " WHERE (((Forms!frmHovedmenu!txtToday) AND Query3.MedID Not In (SELECT AttDate AND AttMed FROM Attend )));"

DoCmd.RunSQL strSQL


Hope u guys can help me :eek:)
 
Use
DoCmd.SetWarnings False

strSQL = "INSERT INTO Attend ( AttMed, AttTeam, AttDate, AttMeetTime, AttType )" _
& " SELECT Query3.MedID, Query3.TeamNo, Forms!frmHovedmenu!txtToday, Query3.MeetTime, 1" _
& " FROM Query3" _
& " WHERE (((Forms!frmHovedmenu!txtToday) AND Query3.MedID Not In (SELECT AttDate AND AttMed FROM Attend )));"

DoCmd.RunSQL strSQL

DoCmd.SetWarnings True

That will suppress the error message.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top