Conditional Subforms Possible?

J

Jason Lopez

I am working on a form that uses a base parent form. But based on the
information in the parent form, the subform needs to be different. Here's
what I mean:

Parent form is a form indicating classes available. It shows start date,
where the class is being held, etc. The subform is a listing of the
enrolled students and the objectives that need to be completed. The
difference comes in that each class has different objectives and I don't
want to have to create a subform for each class. Is there a way to code the
form so that when I select class A1, subform (roster) A will appear? Then
when I switch to class A2, subform (roster) B will appear? The classes run
at multiple times throughout the year. I just want to somehow try and make
sure that user-friendliness of the form is as gentle on the user as
possible.

Jason Lopez
 
A

Andy Hull

Hi Jason

You can change which form is used as the subform with the following code...

Me.subfrm_name.SourceObject = "frmMyForm1"

where subfrm_name is the name you gave to the subform control within the
main form and frmMyForm1 is the name of the form you want to use as the
subform (as it appears in the forms window).

You can also change the link fields if necessary...

Me.subfrm_name.LinkChildFields = "child_field_name"
Me.subfrm_name.LinkMasterFields = "parent_field_name"

Having said this you may be able to design your tables so you don't have to
have different "views" for each class - although, of course, I don't know the
full scenario.

If you have...

tblClasses
tblStudents
tblObjectives

you could define each class' objectives with table...

tblClassObjectives
Columns...
ClassID
ObjectiveID

and if you need to store the objectives per student...

tblStudentClassObjectives
StudentID
ClassID
ObjectiveID
....other columns... eg objective_reached_date etc

This way, the structire would be the same for every class and you could use
the same form design.

hth

Andy Hull
 

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