Clearing Field after Duplicate

  • Thread starter Thread starter Bob
  • Start date Start date
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
 
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
 
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


.
 
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
 
Back
Top