Solved

Copy data from one subform to another - MS Access

Posted on 2016-10-27
3
29 Views
Last Modified: 2016-11-04
I have an Access database that has a form with 2 subforms on it.  Subform1's record source is MyTable. Subform2's record source is MyTemporaryTable.   In the detail section of Subform1 (displayed as continuous forms), in addition to the table's fields displayed in textboxes, I have a command button that I intend to use as a "select" button.  the "select" button appears next to every record displayed in Subform1.

I want to be able to 'select' a record from Subform1 and have it copied into Subform2 (i.e. populate the temporary table with that record).

So, my question is related to the action of the 'select' button in Subform1.  How do I get it to copy the selected record from Subform1 and populate Subform2 (and thereby save it to the temporary table)?

If it isn't that complex of a solution, then it would also be great if someone could show me how to also 'deselect' a record from Subform2 (i.e. I would also put a command button in Subform2 like I have in Subform1 except its purpose would be to delete the record from the temporary table in the event the user made a mistake and selected the wrong record from Subform1).

The data needs to be saved to the temporary table as I will be doing something additional with the data in the near future, so I don't want to just populate subform2.  I need the selected data to actually be saved to the temporary table.

Thank you
0
Comment
Question by:dbfromnewjersey
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 41862777
this type of problem needs a working db...
please don't expect the experts to create a sample db to simulate your db.

upload a copy of the db.
0
 

Author Comment

by:dbfromnewjersey
ID: 41862974
I'll upload one shortly
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41864144
The copy would be done with a select query.  The select query's WHERE clause references the selected record in sfrm 1 and appends the record to the table of sfrm 2 (probably changing some value rather than copying all the fields.  For example.

Insert Into tbl2(fld1, fld2, fld3)
Select  fld1, fld2, "Newvalue"
From tbl1
Where tbl1.ID = Forms!yourform!yoursubform.Form!IDfield;
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now