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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy most current records from table to sub form

Status
Not open for further replies.
Feb 4, 2009
137
US
Please help, I'm very appreciated...
Thank you very much.

I have a main form with several sub forms, each sub form on each tab. The main form has a button "Add New". So when hitting the "Add New" button to add a new record, then the second sub form should be automatical inserted the most current records (one to many relationship) from the last inspection into the table and show on the sub form on the second tab.

I had created the query for the most current records with results:

qryMostCurrentNonViolation
Estab. No Inspection No Date Inspection NonVio No Documentation repeat
20922 218959 5/10/2011 1 test 1 0
20922 218959 5/10/2011 2 test 2 2
20922 218959 5/10/2011 3 test 3 1
26906 218959 5/14/2011 1 test 1 0
26906 218959 5/14/2011 2 test 2 3
26906 218959 5/14/2011 3 test 3 1
26906 218959 5/14/2011 4 test 4 2
23198 218867 10/11/2011 1 test 1 1
and so on...

So for instance, on main form I enter establishno = 26906 then enter the rest of data, then click on the button "Add New", then the new Inspection No will be generated by the system with the new Inspection = 222222 (tblInspection : on the main form)

The results on my sub form should be:

tblNonViolation (primary keys: inspectionNo and VioNo) (repeat = repeat.value + 1)
InspectionNo VioNo Documentation Repeat
222222 1 test 1 1
222222 2 test 2 4
222222 3 test 3 2
222222 4 test 4 3
Please help,
again, thank you very much.
Twee
 
and all my sub forms linked the main form with the Inspection No.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top