Clearing Field after Duplicate

B

Bob

The code listed informs me that another telephone exist.
What additional code is necessary to clear the field and
begin reentering another telepnone nember after
selecting "ok" when the error appears?


Private Sub Telephone_BeforeUpdate(Cancel As Integer)
Dim x As Variant

x = DLookup("[Telephone]", "Realtor List", "[Telephone]
= '" _
& Forms!RealtorList!Telephone & "'")

On Error GoTo realid_err

If Not IsNull(x) Then
Beep
MsgBox "Duplicate TELEPHONE Entry",
vbOKOnly, "DUPIPLICATE VALUE"
Cancel = True
End If

realid_exit:
Exit Sub

realid_err:
MsgBox Error$
Resume realid_exit
End Sub
 
J

John Vinson

The code listed informs me that another telephone exist.
What additional code is necessary to clear the field and
begin reentering another telepnone nember after
selecting "ok" when the error appears?

Me![Telephone].Undo
 
G

Guest

Were is this inserted and is it this line only?
-----Original Message-----
The code listed informs me that another telephone exist.
What additional code is necessary to clear the field and
begin reentering another telepnone nember after
selecting "ok" when the error appears?

Me![Telephone].Undo


.
 
J

John Vinson

Were is this inserted and is it this line only?

Sorry!

Private Sub Telephone_BeforeUpdate(Cancel As Integer)
Dim x As Variant

x = DLookup("[Telephone]", "Realtor List", _
"[Telephone]= '" _
& Forms!RealtorList!Telephone & "'")

On Error GoTo realid_err

If Not IsNull(x) Then
Beep
MsgBox "Duplicate TELEPHONE Entry", _
vbOKOnly, "DUPIPLICATE VALUE"
Me.Telephone.Undo
Cancel = True
End If

realid_exit:
Exit Sub

realid_err:
MsgBox Error$
Resume realid_exit
End Sub
 
Top