find duplicates problem with code

cliff7376

Registered User.
Local time
Today, 15:59
Joined
Oct 10, 2001
Messages
107
i got this code from this site and i guess i'm not too bright.
If Me.NewRecord Then
If Not IsNull(DLookup("PrimaryID", "TableName", "[PrimaryID] = " & Me.PrimaryID)) Then
MsgBox "This ID already exists"

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PrimaryID] = " & Me![PrimaryID]
Me.Undo
Me.Bookmark = rs.Bookmark

End If
End If

my text box name on my form is partnbr and my field name in my table tblpartnbr is called partnbr. I have substiuted these names into this code and i just get a compile error. i would really appreciate some help please.

[This message has been edited by cliff7376 (edited 03-19-2002).]
 
It always helps if you post your code because we can't spot errors if we can't see it. Also, what does the error say? Is partnbr a string or number Data Type?
 
it is a string
 
acctually this is the exact code i am using

If Me.NewRecord Then
If Not IsNull(DLookup("partnbr", "tblpartnbr", "[partnbr] = " Me.partnbr)) Then
MsgBox "This ID already exists"

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PrimaryID] = " & Me![PrimaryID]
Me.Undo
Me.Bookmark = rs.Bookmark
 
Set rs = Me.Recordset.Clone
rs.FindFirst "[PrimaryID] = " & Me![PrimaryID]
Me.Undo
Me.Bookmark = rs.Bookmark
Should Be:

Set rs = Me.Recordset.Clone
rs.FindFirst "[partnbr] = " & Me![partnbr]
Me.Undo
Me.Bookmark = rs.Bookmark
 

Users who are viewing this thread

Back
Top Bottom