0

hi how to do insert ignore in access? is access support this function?

CurrentDb.Execute "INSERT IGNORE INTO FullDB (IDProc, IDOp, IDTech) VALUES (" & IDProct & "," & IDOpt & "," & IDTecht & ")"

or how can i do a search for duplicate record first before insert?

thanks

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by isumasama
0

after trying too many times yesterday, i dont think MS Access support INSERT IGNORE.
what i did instead is:
1. get the count for the particular record.. if there's record then >0
2. use the if statement before inserting any record.

dim temp as string

'1.
temp = DCount("ID", "FullDB", "IDProc = " & IDProct & "AND IDOp = " & IDOpt & "AND IDTech = " & IDTecht & "")

'2.
If temp = 0 Then
    CurrentDb.Execute "INSERT INTO FullDB (IDProc, IDOp, IDTech) VALUES (" & IDProct & "," & IDOpt & "," & IDTecht & ")"
   
ElseIf temp > 0 Then

MsgBox "The record you try to add is already exists. Please refill the form.", vbExclamation

End If

Edited by isumasama: correction

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.