Change Subform based on record selection

S

shmoussa

Hi,

I have a main form. On this main form there is a subform1 with a list
of questions listed in datasheet view. Ideally, I would like there to
be another subform2 that updates based on the selected record.

For example, in subform1- I select the statement "Enter your age
details," then subform2 will change to have a textbox for Age, DOB,
Time of Birth, etc. Then when I select another statement from
subform1, subform2 will change again.

Is there any way to accomplish this? Or is there a better suggestion
to gather specific information from a user based on the question they
selected? Any suggestions would be much appreciated. Thank you.
 
J

Jon Lewis

One way would be to have a stack of subforms (2a, 2b etc for example) all of
the same size and position on the main form and make the relevant subform
control visible and the others invisible in the Current Event of subform1.

You could also try using a Tab control with a subform on each tab switching
tabs as necessary. I think you can make the tabs themselves invisible which
may look better in this scenario.

Also it sounds like it may be better to display your list of questions in a
ListBox rather than subform1 in which case you could use the After Update
event of the ListBox to switch subform2s.

If there's too many subform1 records (questions) to make the above practical
then you could look at dynamically setting the SourceObject of one subform2
control using the events above.

HTH

Jon
 
S

shmoussa

One way would be to have a stack of subforms (2a, 2b etc for example) allof
the same size and position on the main form and make the relevant subform
control visible and the others invisible in the Current Event of subform1..

You could also try using a Tab control with a subform on each tab switching
tabs as necessary.  I think you can make the tabs themselves invisible which
may look better in this scenario.

Also it sounds like it may be better to display your list of questions ina
ListBox rather than subform1 in which case you could use the After Update
event of the ListBox to switch subform2s.

If there's too many subform1 records (questions) to make the above practical
then you could look at dynamically setting the SourceObject of one subform2
control using the events above.

HTH

Jon









- Show quoted text -

Thank you for the response. There are going to be many questions
(possibly over 40) questions so your fourth option might be the best
one. But, not knowing anything about SourceObject, I wouldn't know
where to start. I'll do some research but if you could provide some
insight too- that would be great.

One option I noticed is to have a split form, with the datasheet on
top, listing all of the questions and response boxes- and the form
version by itself. Would there be an easy way to change that form in
the split form, based on the record selection?
 
J

Jon Lewis

See inline:

One way would be to have a stack of subforms (2a, 2b etc for example) all
of
the same size and position on the main form and make the relevant subform
control visible and the others invisible in the Current Event of subform1.

You could also try using a Tab control with a subform on each tab
switching
tabs as necessary. I think you can make the tabs themselves invisible
which
may look better in this scenario.

Also it sounds like it may be better to display your list of questions in
a
ListBox rather than subform1 in which case you could use the After Update
event of the ListBox to switch subform2s.

If there's too many subform1 records (questions) to make the above
practical
then you could look at dynamically setting the SourceObject of one
subform2
control using the events above.

HTH

Jon









- Show quoted text -

Thank you for the response. There are going to be many questions
(possibly over 40) questions so your fourth option might be the best
one. But, not knowing anything about SourceObject, I wouldn't know
where to start. I'll do some research but if you could provide some
insight too- that would be great.


When you add a subform to a form you add a subform control and then set the
SourceObject for the control i.e. the form that the subform control displays
(as a subform). If you're running code from the On Current event of
subform1 what I mean is something like this:

Me.Parent.subform2control.SourceObject = "frmSubform2x"

where subform2control is the name of your second subform control (not the
form it displays)

One option I noticed is to have a split form, with the datasheet on
top, listing all of the questions and response boxes- and the form
version by itself. Would there be an easy way to change that form in
the split form, based on the record selection?

Not as far as I know. The split form view in Access 2007 shows a datasheet
and single form view of the same form.

-Jon
 

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