kingesk
03-07-2001, 06:34 PM
I am attempting to code some error handeling when a user trys to AddNew and Update with a primary key that already exist.
The error num I got was '-2147467259(800004005)'
I can't seem to trap this error. Any ideas on how to handle this?
Thanks,
Eric
Private Sub mnuUpdate_Click()
'save the added record
On Error GoTo HandleErrors
mRstCurrent("PubId") = txtID
mRstCurrent("Name") = txtName
mRstCurrent("company Name") = txtCoName
mRstCurrent("Address") = txtAddress
mRstCurrent.Update
txtID.SetFocus
lblRecCount = mRstCurrent.RecordCount
lblRecNum = mRstCurrent.AbsolutePosition
Exit Sub
HandleErrors:
Select Case Err:
Case "'-2147467259(80004005)'"
MsgBox "ID already exist, pick id with a unique value", vbOKOnly
mRstCurrent.CancelUpdate
txtID.SetFocus
Exit Sub
Case Else 'all other errors should cancel execution
Err.Raise Err
End Select
Resume
End Sub
The error num I got was '-2147467259(800004005)'
I can't seem to trap this error. Any ideas on how to handle this?
Thanks,
Eric
Private Sub mnuUpdate_Click()
'save the added record
On Error GoTo HandleErrors
mRstCurrent("PubId") = txtID
mRstCurrent("Name") = txtName
mRstCurrent("company Name") = txtCoName
mRstCurrent("Address") = txtAddress
mRstCurrent.Update
txtID.SetFocus
lblRecCount = mRstCurrent.RecordCount
lblRecNum = mRstCurrent.AbsolutePosition
Exit Sub
HandleErrors:
Select Case Err:
Case "'-2147467259(80004005)'"
MsgBox "ID already exist, pick id with a unique value", vbOKOnly
mRstCurrent.CancelUpdate
txtID.SetFocus
Exit Sub
Case Else 'all other errors should cancel execution
Err.Raise Err
End Select
Resume
End Sub