View Single Post
  #2  
Old June 3rd, 2010, 07:07 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Display a message box "this entry is a duplicate"

Something like:

Private Sub txtShipNum_BeforeUpdate(Cancel As Integer)

If DCount("*", "MyTable", "ShipNum = '" & Me.txtShipNum & "'") 0 Then
Msgbox Me.txtShipNum & " already exists."
Cancel = True
End If

End Sub

This assumes that your text box is named txtShipNum, that the name of the
field in table MyTable is ShipNum and that it's a text field.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
Co-author: Access 2010 Solutions, published by Wiley
(no e-mails, please!)

"Tina" wrote in message
...
How can I display a message box on a form if the shipment number is a
duplicate? I need a message box to pop up when user attempts to tab out
of
the field.

Thank you.