hi
I am building an application in which the user has to enter a ProjectName that is a key (no duplicate). For that I wish to validate the entered value in the Field level (I thank everybody that bothered to respond to my previous thread). I've wrote this piece of code :
_________________________________________________________
Private Sub ProjectName_BeforeUpdate(Cancel As Integer)
Dim strFilter As String
Dim strResult As String
strFilter = "ProjectName = " & Me.ProjectName
strResult = DLookUp("ProjectName", "Projects", strFilter)
If strResult <> Null Then
MsgBox("Name already exist")
Cancel = True
End If
End Sub
_________________________________________________________
While testing the code, I got a Runtime error 2001, specifying that I've canceled previous action ??? and the debugger points to the line containing the DLookUp Function.
Note - I opened the form with acFormAdd.
Thanks in advance for any assistance.
I am building an application in which the user has to enter a ProjectName that is a key (no duplicate). For that I wish to validate the entered value in the Field level (I thank everybody that bothered to respond to my previous thread). I've wrote this piece of code :
_________________________________________________________
Private Sub ProjectName_BeforeUpdate(Cancel As Integer)
Dim strFilter As String
Dim strResult As String
strFilter = "ProjectName = " & Me.ProjectName
strResult = DLookUp("ProjectName", "Projects", strFilter)
If strResult <> Null Then
MsgBox("Name already exist")
Cancel = True
End If
End Sub
_________________________________________________________
While testing the code, I got a Runtime error 2001, specifying that I've canceled previous action ??? and the debugger points to the line containing the DLookUp Function.
Note - I opened the form with acFormAdd.
Thanks in advance for any assistance.
Last edited: