Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a single record to another table 1

Status
Not open for further replies.

rlf1957

IS-IT--Management
Mar 7, 2003
60
US
I need to have a button on my form that will copy the current record shown on the form to another table. I have seen in other posts that it is a simple process to create a duplicate record in the form/table that I'm using but the posts I've searched make the process I need seem very tedious. (field by field, using SQL. Is this actually the easiest way to accomplish this ? if so, I would greatly appreciate a detailed example of the VB needed and where to place it. I am a relative novice at anything but the basic access methods.
Another topic (not sure if it is acceptable to post two questions in one post???) is one that I have seen in older posts but still need further details.
I have a xerox Documate 250 sheet fed scanner. It has a one-touch button on the front. This button scans a single or mult page doc and I have it set to create a PDF file using no UI. I would like to have a button on my form to act like the button on the scanner.
 
Create an append query to append from the forms's recordsource to the other table.
Select the record using a criteria expression which is a reference to the id field on the form:
forms!myform!myidtextbox.

Put a button on the form that run the query.
 
try putting the code on a button

Code:
Private Sub Command39_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.OpenForm "frmDeletedPerson", , , acNew
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close acForm, "frmDeletedPerson"
End Sub
you are selecting a record 
copying a record 
open the other form
pasting the record 
saving the record
closing the form to return you back to where you were

[COLOR=red] Dont forget to change the form name [/color]

Hope this helps
Hymn
 
Thanks very much for both responses. I went with your solution Hymn and it works swimmingly. Now can we take it one step further? I would like to be able to take any of the records that were "archived" and copy them back to the original table/form with the PKey being altered to prevent duplicates which are not allowed. Also, a very small number of the fields need to be changed in the "New" record. Your thoughts on this subject are greatly appreciated......
 

Reverse the forms names

acEditMenu, 2, , acMenuVer70 = Copy
acEditMenu, 1, , acMenuVer70 = Cut


In the table that contains the archived data do a delete query and remove the Pkey data.
I normally place something like the code below at the end of the code

Fielda = ""
Fieldb = ""
Fieldc = ""

Then enter data when required

Hope this helps
Hymn
 
Again Hymn,
Thanks for the help, won't be able to try this out until next week. Out of town. Will get backto it Tuesday next.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top