Forum Discussion
Use verification rule to stop input of duplicate values in a field of another form?
Karl,
Thank you very much for your input. I tried what you suggested. However, I keep getting an error where Access is telling me it cannot find the respective field "JOB". As the actual field name in the table is "JOB#", I am wondering if it does not recognize the "#" character. I could try changing the field name in the Sharepoint table to what you have in your code as "JobNo". However, I fear this may break other relationships within the database after update. Here is the code I entered in the BeforeUpdate area of the textbox control.
If Not IsNull(Dlookup("JOB#", "JOB_TABLE", _
"JOB# = " & Me!JOB#)) _
And Me!JOB# <> nz(Me!JOB#.OldValue) Then
MsgBox Me!JOB# & " already exists.", vbOKOnly, "Duplicate!"
Cancel = True
End If
Thoughts?
Hi,
Special characters like # in object or field names very often cause problems and should be avoided. If you are able to change that name then do it ASAP. Meanwhile you have to always enclose the name in square brackets:
If Not IsNull(Dlookup("[JOB#]", "JOB_TABLE", _
"[JOB#] = " & Me![JOB#])) _
And Me![JOB#] <> nz(Me![JOB#].OldValue) Then
MsgBox Me![JOB#] & " already exists.", vbOKOnly, "Duplicate!"
Cancel = True
End If
Servus
Karl
*********
http://AccessDevCon.com
https://www.donkarl.com