mike-davies
New member
- Local time
- Today, 22:46
- Joined
- Nov 19, 2006
- Messages
- 5
I have a simple table called "dummy" with one field that is the primary unique key. The following code does NOT produce a duplicate key error. Why is that ?
Private Sub Form_Load()
Dim dbsCurrent As dao.Database
Set dbsCurrent = CurrentDb()
On Error GoTo ooops
dbsCurrent.Execute "insert into dummy (mykey) values (1)"
dbsCurrent.Execute "insert into dummy (mykey) values (1)"
MsgBox ("I should have a duplicate key error by now." & vbCrLf & Error(err))
GoTo ok
ooops:
MsgBox (Error(err))
ok:
End Sub
Private Sub Form_Load()
Dim dbsCurrent As dao.Database
Set dbsCurrent = CurrentDb()
On Error GoTo ooops
dbsCurrent.Execute "insert into dummy (mykey) values (1)"
dbsCurrent.Execute "insert into dummy (mykey) values (1)"
MsgBox ("I should have a duplicate key error by now." & vbCrLf & Error(err))
GoTo ok
ooops:
MsgBox (Error(err))
ok:
End Sub
Last edited: