C
cmichaud
I have a form with primary key and first and last name. i want to stop
a user from entering the same first and last name. this is what i have
for vb code.
Private Sub FirstName_AfterUpdate()
If Not IsNull(DLookup("[LastName]", "tblPersonalInfo", "[LastName] = '"
& Me.[LastName] & "' And [FirstName] = '" & Me.[FirstName] & "'")) Then
MsgBox "The name you entered is already listed in the database. Use the
Find button to locate the record."
Me.LastName = Null
Me.FirstName = Null
Me.LastName.SetFocus
Me.Undo
End If
End Sub
This works fine in that it deletes the fields and the user can enter a
new name. However...it doesnt delete the primary key so the database
ends up have a record set with nothing in it. I want it to delete the
primary key to. So if i enter john smith (member id 47) and john smith
is in the database already....it will let me enter in sam smith....and
not bump the user id to 48.
Any ideas. Thanks
a user from entering the same first and last name. this is what i have
for vb code.
Private Sub FirstName_AfterUpdate()
If Not IsNull(DLookup("[LastName]", "tblPersonalInfo", "[LastName] = '"
& Me.[LastName] & "' And [FirstName] = '" & Me.[FirstName] & "'")) Then
MsgBox "The name you entered is already listed in the database. Use the
Find button to locate the record."
Me.LastName = Null
Me.FirstName = Null
Me.LastName.SetFocus
Me.Undo
End If
End Sub
This works fine in that it deletes the fields and the user can enter a
new name. However...it doesnt delete the primary key so the database
ends up have a record set with nothing in it. I want it to delete the
primary key to. So if i enter john smith (member id 47) and john smith
is in the database already....it will let me enter in sam smith....and
not bump the user id to 48.
Any ideas. Thanks