Run-Time Error 2001

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
Dim Check As Integer


Dim 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 If




End Sub




Every time, I am trying to run the application, when the LastName_AfterUpdate event is called, :mad: I keep receiving a Run-time Error '2001' stating "You canceled the previous operation":mad: . Of course, there is nothing in the help file to explain me what is going on.

Could you please help me? :confused:

Thanks beforehand,

Mr. Guilbeau
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top