H
Hilary Ostrov
I have a txtfield [SiteID] that is a required field - indexed (No
Duplicates)
The following code (which I found courtesy of John someone's post of
2002) does work, but only if I set Required = No.
Private Sub SiteID_BeforeUpdate(Cancel As Integer)
'If user enters SiteID that is a duplicate
Cancel = (DCount("*", "Jobsites", "[SiteID]=""" & Me.SiteID.Text &
"""") > 0)
If Cancel = True Then
MsgBox "This SiteID already exists. Please choose another one",
vbOKOnly
End If
End Sub
However, if I set Required = Yes, then this code still works, but is
invariably followed by a considerably less than user-friendly MS
Access error msg.
What do I need to do to get rid of the MS Access message?
TIA for any suggestions.
hro
Duplicates)
The following code (which I found courtesy of John someone's post of
2002) does work, but only if I set Required = No.
Private Sub SiteID_BeforeUpdate(Cancel As Integer)
'If user enters SiteID that is a duplicate
Cancel = (DCount("*", "Jobsites", "[SiteID]=""" & Me.SiteID.Text &
"""") > 0)
If Cancel = True Then
MsgBox "This SiteID already exists. Please choose another one",
vbOKOnly
End If
End Sub
However, if I set Required = Yes, then this code still works, but is
invariably followed by a considerably less than user-friendly MS
Access error msg.
What do I need to do to get rid of the MS Access message?
TIA for any suggestions.
hro