Consistant error

C

Curt

I tried multiple different changes, but without any luck
maybe someone here can help out on what I am doing wrong.
I keep getting a message:

The changes you requested to the table were not successful
because they could create duplicate values in the index,
primary key, or relationship. Change the value in the
fields or fields that contain duplicate data, remoce the
index, or redifine the index to permit duplicate entries
and try again. Now here is my code that I am using and I
get seem to figure out what is wrong.

vSSAN = Me.Parent.FMP.Column(0) & "/" & Me.Parent.SSAN
& " " & Me.Parent.FName & " " & Me.Parent.LName

End If
Set dbs = CurrentDb()
Set rst = OpenForSeek("tblFAM")
rst.Index = "SSAN"
rst.Seek "=", vSSAN
If Not rst.NoMatch Then
rst.Edit
rst.Update
rst.Close
dbs.Close
Else
Set rst = dbs.OpenRecordset("tblFAM")
rst.AddNew
rst![SSAN] = vSSAN
rst.Update
rst.Close
Me.Parent.FAMList.Requery
End If
 
C

Curt

Never mind I fixed it for some reason it was trying to
create 2 records at the same time. I took out the
following
Set rst = dbs.OpenRecordset("tblFAM")
rst.AddNew
rst![SSAN] = vSSAN
rst.Update
rst.Close

and it still created a record if needed.
-----Original Message-----
I tried multiple different changes, but without any luck
maybe someone here can help out on what I am doing wrong.
I keep getting a message:

The changes you requested to the table were not successful
because they could create duplicate values in the index,
primary key, or relationship. Change the value in the
fields or fields that contain duplicate data, remoce the
index, or redifine the index to permit duplicate entries
and try again. Now here is my code that I am using and I
get seem to figure out what is wrong.

vSSAN = Me.Parent.FMP.Column(0) & "/" & Me.Parent.SSAN
& " " & Me.Parent.FName & " " & Me.Parent.LName

End If
Set dbs = CurrentDb()
Set rst = OpenForSeek("tblFAM")
rst.Index = "SSAN"
rst.Seek "=", vSSAN
If Not rst.NoMatch Then
rst.Edit
rst.Update
rst.Close
dbs.Close
Else
Set rst = dbs.OpenRecordset("tblFAM")
rst.AddNew
rst![SSAN] = vSSAN
rst.Update
rst.Close
Me.Parent.FAMList.Requery
End If
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top