Subform with one to many relationship

D

dBNovice

Hello all, I posted this question previously but did not get suffient
help. (perhaps my question was not worded properly; hopefully this is
better) If possible, I really need help on this one............

I have 3 tables and corresponding forms: tasks, subtasks and elements.
subtasks is a subform of tasks and elements is a subform of subtasks.
I have all 3 forms on a tab control with 3 pages. There is a one to
many relationship with task <-> subtasks; subtasks <-> elements and
task <-> elements. I am able to insert a task and 1 associated subtask
and 1 element. The problem exists when I try to put multiple subtasks
and elements associated with one task. Is there a way to navigate to a
new record and automatically set the value of either the taskID on the
Subtasks subform or subtaskID on the Elements subform to link the new
subform/element to the initial Task. (i.e. I want to input a task w/
TaskID: 111 and a subtask with TaskID: 111 and SubtaskID: 01 and
another subtask with TaskID: 111 and SubtaskID: 02; then an element
with TaskID: 111 and SubtaskID: 01 and ElementID: 1 and another element
with TaskID: 111 and SubtaskID: 01 and ElementID: 2.

On the Subtasks subform: Link Child Fields...TaskID and the Link Master
Fields...Tasks.TaskID

On the Elements subform: Link Child Fields...SubtaskID and the Link
Master Fields...Subtasks.SubtaskID

Note: not all tasks have multiple subtasks or elements; a task could
have 0 subtask but must have an element (element contains due date).
 
A

aaron.kempf

do you keep subtasks and elements in the same table?

if not then you should have 2 subforms.

almost all subforms are based on a one to many relationship.. shoudl be
pretty cut and dry.

Are you hoping to set up your subform in datasheet view?

go into the subform and set the default view to datasheet then

-Aaron
 
A

Amy Blankenship

dBNovice said:
Hello all, I posted this question previously but did not get suffient
help. (perhaps my question was not worded properly; hopefully this is
better) If possible, I really need help on this one............

I have 3 tables and corresponding forms: tasks, subtasks and elements.
subtasks is a subform of tasks and elements is a subform of subtasks.
I have all 3 forms on a tab control with 3 pages. There is a one to
many relationship with task <-> subtasks; subtasks <-> elements and
task <-> elements. I am able to insert a task and 1 associated subtask
and 1 element. The problem exists when I try to put multiple subtasks
and elements associated with one task. Is there a way to navigate to a
new record and automatically set the value of either the taskID on the
Subtasks subform or subtaskID on the Elements subform to link the new
subform/element to the initial Task. (i.e. I want to input a task w/
TaskID: 111 and a subtask with TaskID: 111 and SubtaskID: 01 and
another subtask with TaskID: 111 and SubtaskID: 02; then an element
with TaskID: 111 and SubtaskID: 01 and ElementID: 1 and another element
with TaskID: 111 and SubtaskID: 01 and ElementID: 2.

On the Subtasks subform: Link Child Fields...TaskID and the Link Master
Fields...Tasks.TaskID

On the Elements subform: Link Child Fields...SubtaskID and the Link
Master Fields...Subtasks.SubtaskID

Note: not all tasks have multiple subtasks or elements; a task could
have 0 subtask but must have an element (element contains due date).

The way forms and subforms are designed to work is that the main form refers
to the top level table. In your case, this would be Tasks. The subform
then refers to the child table (subtasks). A subform on that form would
then refer to the third level (items). If you establish your relationships
properly and then create your forms this way, Access will handle the whole
thing automagically.

The whole tab thing you want to do is pretty messy from a UI point of view
and would require a lot of scripting. I'm guessing that you're fairly new
to Access, and so you may not choose to try to script this. Post back if
you really DO want to script the whole thing, but I advise you to simply use
Access the way it was designed.

HTH;

Amy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top