Link to home
Start Free TrialLog in
Avatar of mona4980
mona4980

asked on

create records then auto populate on open

this is the scenario. I have a form based on a tblBudgetHeader called frmDailyHeader. on that form I have info such as date and other daily information that is common for all the divisions that I will be entering. I also have a sub form that has information I need to enter for each individual division of the company. The sub form is linked to the header so for each day there should be a record. The sub form is datasheet. So that the person doing the data entry is entering information for each division I need the sub form to create a new record for each division and populate the sub form when a new daily entry is made. So I will have something open the form frmDailyHeader and I assume that I will put some kind of code in the on open event. But what?
Avatar of Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Flag of United States of America image

I would use the On Current event to test for we new record. Then run an append query to all all teh record for the parent record into the child/related table. You would then requery  the sub form control to show the new record read for data entry.
Avatar of mona4980
mona4980

ASKER

So how do I get the new record for all of the divisions?
You see I have 6 divisions. When somebody creates a new day I want all 6 divisions to auto populate in the sub form waiting to be updated.  
I would assume that you have a divisions look up table.

You would select all the division records from teh at table and  append the division ID  into the related/child table adding the primary key from the parent form so they are linked.

Here is an example that takes all the products and adds then to an order

INSERT INTO [Order Details] ( ProductID, OrderID )
SELECT Products.ProductID, forms!Invoice.OrderID  AS OID
FROM Products;

Open in new window


I have a divisions table tblBUDIV the PK is BUDIVID. for the main form I have tblBUDAILYHEADER and the PK is BUDAILYHEADERID. In that table I have BUENTRYID . That links the table for the sub form, tblBUDAILYENTRY, that keeps the information for the individual divisions. tblBUDAILYENTRY PK is BUENTRYID and
and BUDIVID. does that help?
ASKER CERTIFIED SOLUTION
Avatar of Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your help. By using that saved query it populated the form.