Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing Duplicate Record Entry on Form.

Status
Not open for further replies.

tmpark

Technical User
Nov 15, 2002
24
0
0
US
I've searched the threads and have come up with good advice but I'm having trouble implementing the solution. Any help you can provide is most appreciated.

I have a form, frmPROPERTY, with a field, PROP_ID, from the table tblPROPERTY. I need to display a message whenever someone enters a PROP_ID that is already in a previous record. I found the following script and tried it in After Update but nothing seems to be happening when I enter two of the same Ids.

Private Sub PROP_ID_AfterUpdate()

If DCount("*", "tblPROPERTY", "[PROP_ID]=" & Me.PROP_ID) > 0 Then
MsgBox "This property has apparently been involved in a previous project"
Me.PROP_ID = Null
End If

End Sub

I may be missing something very obvious. PROP_ID is a text field with IDs such as 000-0000 or 000-0000-0000 and no validation rules applied. There are also null values for this field in the table.

Thanks for your help.

I'm also interested in general naming convention for objects and fields if you have an extra second. Thanks.

Trent Park

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top