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

Creating a new record on main & subform

Status
Not open for further replies.

daveh

Technical User
Jun 22, 2000
57
GB
Hi there,

I've got a parent table (unique key ParentID), and a child table (unique key ChildID, secondary key ParentID which relates it to the parent).

I want to have a form that concentrates on the child. So I have created a form based on the child table, and then a subform based on the parent table. The subform is formatted as a single form.

What I want is for the users to be able enter (and view) details of a child, and then to either select which existing parent they belong to using some sort of drop down, and or to enter the details of a new parent along with their child. But I'm running into problems, possibly because of the approach I have taken with the form/subform etc.

If my approach is OK, the specific problem that I'm having relates to adding a record on both forms at the same time, rather than just the form the button with the code behind it is sitting in.

Thanks for any help.
Dave.
 
The usual (and more practical due to referential integrity) way is to have the main form based on the parent table and the subform based on the child table.
Provided the relationships are properly set, the subform wizard will link the two forms automagically.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Right OK, I figured as much. My follow on question would therefore be... rather than viewing the Child subform as a datasheet or continuous set of forms, how can I display them so that its almost as if under each parent there is a child, and then a "add child" button to add additional children?

Secondly, I want a combo at the top of the form where they select one of the children, and after selecting it the appropriate child and parent is loaded on the page. However, because the combo box has to be based on the main form, it only allows you to select items from the Parent form.

Regards,
David.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top