G
Guest
I have tried several things to try to provide the user with a custom error
message when they enter a duplicate key into a key field when creating a new
record. Access's own error message always pops up first, which I don't want.
I tried the following code in several different control or form events to no
avail:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FundNo] = " & Str(Me![FundNo])
If rs.NoMatch Then
' Do nothing
Else
MsgBox "Fund of this number already exists ", vbOKOnly +
vbExclamation, "Enter different fund number . . ."
Cancel = True: Exit Sub
End If
Perhaps this code isn't going to work. I've also tried an error handling
routine, but Access always catches the problem first and displays its own
message. The error handler isn't being tripped.
ctdak
message when they enter a duplicate key into a key field when creating a new
record. Access's own error message always pops up first, which I don't want.
I tried the following code in several different control or form events to no
avail:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FundNo] = " & Str(Me![FundNo])
If rs.NoMatch Then
' Do nothing
Else
MsgBox "Fund of this number already exists ", vbOKOnly +
vbExclamation, "Enter different fund number . . ."
Cancel = True: Exit Sub
End If
Perhaps this code isn't going to work. I've also tried an error handling
routine, but Access always catches the problem first and displays its own
message. The error handler isn't being tripped.
ctdak