From: Brad on
Please help, a clear answer is needed!

If the code below copies the record to the same table... How do you
copy it to another table? I would be happy with this, but next how
would you asign a numeric value in a field of the new record that the
id of another table that is the focus of the main form. The other two
tables are subforms.


Private Sub CpyToPP_Click()
On Error GoTo Err_CpyToPP_Click


DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

Exit_CpyToPP_Click:
Exit Sub

Err_CpyToPP_Click:
MsgBox Err.Description
Resume Exit_CpyToPP_Click

End Sub
From: Tom van Stiphout on
On Sun, 23 May 2010 14:29:14 -0700 (PDT), Brad
<chile.gillie(a)gmail.com> wrote:

For a clear answer we need a clear description of the tables involved:
the major fields, the primary keys, foreign keys, relationships and
unique indexes.

Making an exact copy of a record to another table often points at bad
database design. Tell us why that's not the case here.

Copying data is best done with an Append query.

-Tom.
Microsoft Access MVP



>Please help, a clear answer is needed!
>
>If the code below copies the record to the same table... How do you
>copy it to another table? I would be happy with this, but next how
>would you asign a numeric value in a field of the new record that the
>id of another table that is the focus of the main form. The other two
>tables are subforms.
>
>
>Private Sub CpyToPP_Click()
>On Error GoTo Err_CpyToPP_Click
>
>
> DoCmd.RunCommand acCmdSelectRecord
> DoCmd.RunCommand acCmdCopy
> DoCmd.RunCommand acCmdRecordsGoToNew
> DoCmd.RunCommand acCmdSelectRecord
> DoCmd.RunCommand acCmdPaste
>
>Exit_CpyToPP_Click:
> Exit Sub
>
>Err_CpyToPP_Click:
> MsgBox Err.Description
> Resume Exit_CpyToPP_Click
>
>End Sub