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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top