dbTalk Databases Forums  

How do you make a control button to copy a record to another table?

comp.databases.ms-access comp.databases.ms-access


Discuss How do you make a control button to copy a record to another table? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Brad
 
Posts: n/a

Default How do you make a control button to copy a record to another table? - 05-23-2010 , 04:29 PM






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

Reply With Quote
  #2  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: How do you make a control button to copy a record to another table? - 05-23-2010 , 05:23 PM






On Sun, 23 May 2010 14:29:14 -0700 (PDT), Brad
<chile.gillie (AT) gmail (DOT) 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



Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.