Re: Saving a Newly Created Record

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Bill (wtaylor51537_at_earthlink.net)
Date: 09/04/04


Date: Sat, 04 Sep 2004 20:10:14 GMT

Open the table that contains the detail records in design view. Go to the
icon menu and select the one with the lightning bolt (Indexes). See which
fields have unique indexes. If there is more than one (the primary key)
which is defined as unique, decide if it is necessary, if not change it,
else be sure that value is unique for each new record. Sometimes in the
table or forms control definition, default values violate this and must be
changed.
HTH
"Lloyd" <anonymous@discussions.microsoft.com> wrote in message
news:00eb01c49049$6f356880$a401280a@phx.gbl...
> 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


Quantcast