我正在使用Access数据库。我知道一旦字段在主键中,我们就不能在列中插入相同的值。
我想要什么:
我想使用另一种形式作为警告表单(exp:messageBox.show(this value exist in current table
)而不是ERROR表单:The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
无论如何都可以帮助我做到这一点吗?
答案 0 :(得分:0)
如果您使用的是访问表单,则可以使用OnError()事件来捕获错误并按您希望的方式处理它。
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case Is = 3022
Err.Clear
Response = acDataErrContinue
' The Code you like to use
End Select
Case Else
'handle other Errors
End Sub