repeated information in table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When someone files their application we enter it into an Access form with
their name and other pertinent information. It is okay to have multiple
records with that person but I want a pop-up screen or something to flag that
this person has been here before and may possibly be a duplicate entry for
the same application. Can this be done and can you point me in the right
direction what kind of function I should use to do this lookup? I'm using
Access 2000.
 
Hi, this event detects if you're trying to add a duplicate name to the
database and aborts attempted save.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rst As dao.Recordset
Dim intRespose As Integer
If Me.NewRecord Then
' saving a newrecord to the database
Set rst = Me.RecordsetClone
' check if person has been entered. txtName contains the
' persons name entered to the new record.
rst.FindFirst "Name = '" & txtName & " '"
If Not rst.NoMatch Then
' we found the name in the database already, prompt to add
again.
intRespose = MsgBox ("Person already entered. Add anyway?",
vbYesNo)
If intResponse = vbNo Then
' don't add duplicate name
Cancel = True
End If
Else
MsgBox "New person"
End If
End If
End Sub

It's possible to trap the txtName before update event and abort also.

HTH, Graeme.
 
Back
Top