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!

Conditional display of subform

Status
Not open for further replies.

rorymurray

Programmer
Oct 16, 2001
44
AU
I have a main form which has an area for a subform.

I want to display one of two possible subforms in the main form's subform area based upon the result of a function.
Eg, if functionx()=false, display subform 1, otherwise display subform 2.

Is this possible?

Thanks in advance,

Rory
 
Hi

Yes it possible

if functionx()=false Then
Me.SubFormControlName.SourceObject = "frmSubForm1"
Else
Me.SubFormControlName.SourceObject = "frmSubForm2"
End If

or if you do not want the sub forms to share the same subform control then

if functionx()=false Then
Me.SubFormControlName1.Visible = True
Me.SubFormControlName2.Visible = False
Else
Me.SubFormControlName1.Visible = False
Me.SubFormControlName2.Visible = True
End If




Hope this helps

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Thanks Ken. My only question is, for option 1, where do you enter that code? In the source object?

Rory
 
Hi

With the information I have it is difficult to be sure, but assuming the function acts upon something in the record being displayed, I would say put the code in the oncurrent event of the form.

If your form allows you to amend the field(s) acted upon by the function, you may also need to requery, or repeat the code in the after update event of the field(s) Hope this helps

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top