Saving a Newly Created Record

From: Lloyd (anonymous_at_discussions.microsoft.com)
Date: 09/01/04


Date: Wed, 1 Sep 2004 10:30:54 -0700

My application has a summary table and two detail tables,
with one-to-one relationships between the summary table
and the detail tables. In the summary table I have a
button to go to the detail table. Code behind the button
opens the correct record in the correct detail table or
asks to create a new record. Below is the code to create
a new record in one of the detail tables - it "works"
(displays the correct data in a new record), but I am not
allowed to save the data. It says that I have a duplicate
value in an index.

        If MsgBox("No Tracking Record Found. Create a New
One?", vbOKCancel) = vbOK Then
        DoCmd.OpenForm "frmCTrackGenInfoDE", acNormal, , ,
acFormAdd
        Me.[Grant#] = [Forms]![frmGrantSumDE].[Grant#]
        Forms![frmCTrackGenInfoDE].[Grantee] = [Forms]!
[frmGrantSumDE].[Grantee]
        Else
        MsgBox ("Action Canceled")
        End If

Note, that if I create a detail record that is not linked
to a record in the summary table, it saves fine. Grant#
is the key in all tables. I'm unsure if I need to focus
on the coding, bound fields or the original query to
resolve this problem.

Thanks for any help you can provide.

Lloyd