S.aad
S.aad

Reputation: 538

VBA access insert query does not return an error

I have an Access database and i have a field attributed with unique indexed values. The problem is that when i execute an SQL insert statement with a duplicate value it does not raise an error it rather just skips the statement as if an On Error Resume Next statement is present above it.

Here is the gist of my code CurrentDb.Exceute "Insert Into IS24 (geocodes, realestateId) values (123456, 7788339)" So if 7788339 is already present it will simply not do the insert but would not raise an error either.

Upvotes: 0

Views: 116

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

Try this:

CurrentDb.Execute "Insert Into IS24 (geocodes, realestateId) values (123456, 7788339)", dbFailOnError

Upvotes: 2

Related Questions