Here we go again ... does it ever end??? I'm trying to insert one record into table tblSegment (this is an intersection table). The fields are defined as follows:
seg_projectID is Text
seg_contactID is Long
seg_num is Integer
The primary key is a combination of seg_projectID and seg_contactID
my vars are defined:
Dim strProjectID As String
Dim lngContactID As Long
Here is the code:
' establish this new contact as a research participant
' populate tblSegment records (intersection table) for this contact
lngContactID = Me.contactID
strProjectID = Me.cont_projectID
strSQL = "INSERT INTO tblSegment (seg_projectID, seg_ContactID, seg_num) " & _
"VALUES ('" & strProjectID & "', " & lngContactID & ", " & intSegment & ");"
MsgBox "from CmdDuplicateContact strSQL = " & strSQL
' DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)
The strSQL string looks fine to me, but I get the error:
Microsoft can't append all the records in the append query.
.... it didn't add 1 record(s) to the table due to key violations ...
I can't figure out what the problem is as the values displayed in strSQL in the message box look fine! Both primary key fields are defined as indexed(duplicates ok).
Any help would be greatly appreciated!!! Thanks.
seg_projectID is Text
seg_contactID is Long
seg_num is Integer
The primary key is a combination of seg_projectID and seg_contactID
my vars are defined:
Dim strProjectID As String
Dim lngContactID As Long
Here is the code:
' establish this new contact as a research participant
' populate tblSegment records (intersection table) for this contact
lngContactID = Me.contactID
strProjectID = Me.cont_projectID
strSQL = "INSERT INTO tblSegment (seg_projectID, seg_ContactID, seg_num) " & _
"VALUES ('" & strProjectID & "', " & lngContactID & ", " & intSegment & ");"
MsgBox "from CmdDuplicateContact strSQL = " & strSQL
' DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings (True)
The strSQL string looks fine to me, but I get the error:
Microsoft can't append all the records in the append query.
.... it didn't add 1 record(s) to the table due to key violations ...
I can't figure out what the problem is as the values displayed in strSQL in the message box look fine! Both primary key fields are defined as indexed(duplicates ok).
Any help would be greatly appreciated!!! Thanks.