- Joined
- Jun 28, 2005
- Messages
- 2
- Reaction score
- 0
Hello from Belgium,
In Office Access 2003, I am building an application in which there is a table (tblEmployees) to enter the identification of the employees working in a company.
I am trying to avoid duplicate records by searching the existence or the absence of a duplicate Last Name in the [Last Name] field. I created a VBA code to capture and verify the Last Name but I am facing a problem that I do not find how to solve it as I have verified every single word of my code. Here follows the code:
Private Sub LastName_AfterUpdate() 'LastName being the name of the control for inputting the Last Name
Every time, I am trying to run the application, when the LastName_AfterUpdate event is called,
I keep receiving a Run-time Error '2001' stating "You canceled the previous operation"
. Of course, there is nothing in the help file to explain me what is going on.
Could you please help me?
Thanks beforehand,
Mr. Guilbeau
In Office Access 2003, I am building an application in which there is a table (tblEmployees) to enter the identification of the employees working in a company.
I am trying to avoid duplicate records by searching the existence or the absence of a duplicate Last Name in the [Last Name] field. I created a VBA code to capture and verify the Last Name but I am facing a problem that I do not find how to solve it as I have verified every single word of my code. Here follows the code:
Private Sub LastName_AfterUpdate() 'LastName being the name of the control for inputting the Last Name
Dim Check As Integer
Dim MsgString As String
Check = DCount("[Last Name]", "tblEmployees", "[Last Name]='" & Me![LastName] & "'")
If Check <> 0 Then
End SubDim MsgString As String
Check = DCount("[Last Name]", "tblEmployees", "[Last Name]='" & Me![LastName] & "'")
If Check <> 0 Then
MsgString = ""MsgString = MsgString & "That " & FieldToCheck & " "
MsgString = MsgString & "has already been used!" & Chr(13)
MsgString = MsgString & "Duplicates are unauthorized!"
Me.Undo
Me.Undo
End IfMsgString = MsgString & "has already been used!" & Chr(13)
MsgString = MsgString & "Duplicates are unauthorized!"
Me.Undo
Me.Undo
Every time, I am trying to run the application, when the LastName_AfterUpdate event is called,


Could you please help me?

Thanks beforehand,
Mr. Guilbeau