C
Cameron Dockstader
I have a funtion 'CheckEENum()' set as the BeforeUpdate property on an
'Employee Add' type of form. As far as I can tell, the function runs as
advertised, alerting the data entry team member that the Employee Number
entered is already in use. However, on the first atempt to enter a
non-unique value, the user also gets the following errer:
'The value in the field or record violates the validation rule for the
record or field.'
This error is obviously not needed, and confuses the data entry person, does
anyone know how to supress it? I've tried SetWarnings = false, and do not
use the Msgbox Err.Description function at all. I'm sure it's something
simple I've never ran into.
Thanks!
Function CheckEENum()
On Error GoTo ErrHand
DoCmd.SetWarnings False
Dim frm As String
Dim var As Variant
Dim frmB As Form
frm = Screen.ActiveForm.Name
frm = "Forms!" & frm
var = (DLookup("EmployeeNumber", "tblEmployees", "IDEmployee = " & frm &
"![IDEmployee]"))
Set frmB = Screen.ActiveForm
If frmB!EmployeeNumber = var Then
Exit Function
Else
If IsNull(DLookup("LName", "tblEmployees", "[EmployeeNumber] = " &
frm & "!EmployeeNumber")) = False Then
MsgBox "The Number Entered Is Currently In Use, Please Enter A
Unique Number"
DoCmd.CancelEvent
End If
End If
Exit Function
ErrHand:
ErrMsg ("eM-404")
End Function
'Employee Add' type of form. As far as I can tell, the function runs as
advertised, alerting the data entry team member that the Employee Number
entered is already in use. However, on the first atempt to enter a
non-unique value, the user also gets the following errer:
'The value in the field or record violates the validation rule for the
record or field.'
This error is obviously not needed, and confuses the data entry person, does
anyone know how to supress it? I've tried SetWarnings = false, and do not
use the Msgbox Err.Description function at all. I'm sure it's something
simple I've never ran into.
Thanks!
Function CheckEENum()
On Error GoTo ErrHand
DoCmd.SetWarnings False
Dim frm As String
Dim var As Variant
Dim frmB As Form
frm = Screen.ActiveForm.Name
frm = "Forms!" & frm
var = (DLookup("EmployeeNumber", "tblEmployees", "IDEmployee = " & frm &
"![IDEmployee]"))
Set frmB = Screen.ActiveForm
If frmB!EmployeeNumber = var Then
Exit Function
Else
If IsNull(DLookup("LName", "tblEmployees", "[EmployeeNumber] = " &
frm & "!EmployeeNumber")) = False Then
MsgBox "The Number Entered Is Currently In Use, Please Enter A
Unique Number"
DoCmd.CancelEvent
End If
End If
Exit Function
ErrHand:
ErrMsg ("eM-404")
End Function