CharlieT302
Instructor
Hello Everyone,
I am trying to guard against a person entering a duplicate value in a form. I needs this to be done programmatically and not thru the table properties. I can use a simple Dlookup to search for a duplicate value. However, I want to also try to account for typos where an extra space is included or where one is removed.
A Replace function should do this, but I am having difficulty creating a Dlookup function that incorporates it.
Here is what I need:
As the user enters a value, the program checks the field in the underlying table for a stored value matching the one being typed. If found, it disallows it. This means I have to compare a "trimmed" user-entry to a "trimmed" stored value.
Form Field = Cont_Group
Formula to incorporate = Replace([Cont_Group], " ", "")
How do I add the above formula to the Dlookup below to accomplish this?
If DLookup("Cont_Group", "tbl_Contract_Group_List", "Cont_Group = '" & Me.Cont_Group & "'") > 0 Then
Me.Undo
Cancel = True
GoTo exit_sub
Else
GoTo exit_sub
End If
Thanks in advance
I am trying to guard against a person entering a duplicate value in a form. I needs this to be done programmatically and not thru the table properties. I can use a simple Dlookup to search for a duplicate value. However, I want to also try to account for typos where an extra space is included or where one is removed.
A Replace function should do this, but I am having difficulty creating a Dlookup function that incorporates it.
Here is what I need:
As the user enters a value, the program checks the field in the underlying table for a stored value matching the one being typed. If found, it disallows it. This means I have to compare a "trimmed" user-entry to a "trimmed" stored value.
Form Field = Cont_Group
Formula to incorporate = Replace([Cont_Group], " ", "")
How do I add the above formula to the Dlookup below to accomplish this?
If DLookup("Cont_Group", "tbl_Contract_Group_List", "Cont_Group = '" & Me.Cont_Group & "'") > 0 Then
Me.Undo
Cancel = True
GoTo exit_sub
Else
GoTo exit_sub
End If
Thanks in advance