PDA

View Full Version : Copy Field from Main Form to Subform



Grega
06-26-2020, 01:48 PM
Hi,
From the instructions in the link below I have made an example of how to copy data from main form into a suborm. This works just fine when you pressed the "Command 01" button.
However, how could I do exactly the same example but to click on the Command 02 button, so that button is on main form? I am having a problem setting up a code??

Can anyone write me a code?

I have also attached an Access example.

link: https://sites.google.com/site/sharepointhill/tutorials/msaccess/copy-field-from-main-to-subform


Thank you!
Greg

OBP
06-27-2020, 03:00 AM
Before going in to how to do it, I have to ask why would you want to?
The whole point of relational databases is to enter data once and then refer to it.
That is what Queries are for, ie bringing together the data from various tables.

Grega
06-27-2020, 03:22 AM
Hi, I just figured out how to do it. This is the code:

Forms!frm_Main.frm_sub_A.Form.aField_01 = Forms!frm_Main.Field_01
Forms!frm_Main.frm_sub_A.Form.aField_02 = Forms!frm_Main.Field_02


In fact, it’s just a test form so I understand how it works.
In reality, I want to have similar input mask where, when a button is clicked, certain data (not all) is transferred to the general ledger.


Thanks for the help so far

OBP
06-27-2020, 03:43 AM
You do not need the Subform, unless you want it for display purposes to do the transfer.
It can be done directly to the table using a recordset.
I use that to balance stocks when sales are made and that kind of work.
Let me know if you want or need to do that kind of thing.