I have a question involving a VBA procedure on Access forms. I'm doing some pro-bono work for a charity, and have gotten in over my head. I am new to VBA in the last two weeks, so please respond to this in a pretty basic level. Thanks.
I have a form called frmDonations with a subform. Behind the master form is the tblDonations with data on things related to donations received (Payee, CheckNo, CheckDate, etc.). Behind the subform is tblLineItems with data on what the payment was for, possibly several things in some instances. tblLineItems is linked to tblDonations with a many-to-one relationship using PaymentID as the common field. It's very similar to the structure of an invoice: for each invoice there are multiple lineitems in the sale. I just break down the transaction at the back end, with the receipt of the donation payment.
I actually have two versions of this scenario, one for complex transactions (involving multiple lineitems with the lineitem data being manually entered), and one for simple transactions (the norm, with only one lineitem involving the same data each time). The complex scenario is easy and is working fine. Now I want to set up a separate simple scenario in which the subform table's data is populated automatically, preferably with no visible presence on the master form. Ideally there would be no subform at all in the simple scenario.
I have tried writing code to run in the master form to write to the subform controls, but VB doesn't seem to like that. Similarly I have tried to write code in the subform to read data from the master form, and some constants, but I can't get that code to trigger (what event would you base it on?) Complicating things seems to be that I have several fields in the master that are required, so the writing to the subform data can't occur until all the fields in the master have been entered.
At its heart, I think my problem lies in my unfamiliarity with how to write to the child table. I don't know how to trigger the generation of a new record in that table that will recognize the link to the master table. That happens automatically when you enter data manuall into the subform. How do I mirror that action with VB code?
I am using Access 2003.
Hopefully I have given you enough to go on here. Thanks in advance for your help.