Opening Sub Forms
am 11.10.2007 21:39:45 von feeman
I have a form with a sub form already in it, but what I want to do is
on the form if the age of the person is greater than 25 then it
displays another sub form with different data on it. But if they are
less than 25 the form never appears. Any ideas.
Re: Opening Sub Forms
am 11.10.2007 22:53:57 von Arc
It's easy enough if you have 2 forms that are subforms, and you just want to
shuttle one or the other into the subform control.
On the form's On_Load (I say on load, because at this point, your age field
would have data that you can read), you would do the following:
if me!Age > 25 then
me!subformCtrlName.sourceobject = "Subform2"
end if
The above assumes that you have a subform control that is already set to use
Subform1 (the default when age is 25 or less). So if the age requirement is
true, you would do nothing and have the proper subform appear by default.
Or, you can unbind the subform so it has no sourceobject (just clear the
soureobject of the control), and use the following code:
if me!Age > 25 then
me!subformCtrlName.sourceobject = "Subform2"
else
me!subformCtrlName.sourceobject = "Subform1"
end if
"feeman" wrote in message
news:1192131585.733220.82760@r29g2000hsg.googlegroups.com...
>I have a form with a sub form already in it, but what I want to do is
> on the form if the age of the person is greater than 25 then it
> displays another sub form with different data on it. But if they are
> less than 25 the form never appears. Any ideas.
>
Re: Opening Sub Forms
am 12.10.2007 15:47:20 von feeman
Sorry for this little bit confused. I have a main form with 2 sub
forms on it 1 sub form is always dispalyed no matter what, but the
other one is dependant on age. In the age is greater than 25 the
subform 2 does not appear, if the age is below 25 subform 2 appears.
is this the same code as above to acieve this.
if me!Age < 25 then
me!subformCtrlName.sourceobject = "Subform2"
end if
and what would be the subformcontrolname, i have tried a few things as
is this not what is needed to open the form.
Re: Opening Sub Forms
am 12.10.2007 17:04:13 von Arc
Oh, I see. I thought you meant you had only one subform control, and wanted
to have a different form displayed based on their age. If you have 2
controls, then it's even easier.
subformCtrlName is just the actualy name of the subform control...
I'll put it like this then:
if me!Age > 25 then
me![enter control name for subform 2 here].visible = true
else
me![enter control name for subform 2 here].visible = false
end if
The above assumes now that you have 2 subform controls on the main form.
Hope this helps,
"feeman" wrote in message
news:1192196840.084118.86540@z24g2000prh.googlegroups.com...
> Sorry for this little bit confused. I have a main form with 2 sub
> forms on it 1 sub form is always dispalyed no matter what, but the
> other one is dependant on age. In the age is greater than 25 the
> subform 2 does not appear, if the age is below 25 subform 2 appears.
> is this the same code as above to acieve this.
>
> if me!Age < 25 then
> me!subformCtrlName.sourceobject = "Subform2"
> end if
>
> and what would be the subformcontrolname, i have tried a few things as
> is this not what is needed to open the form.
>