context sensitive forms

G

Gary

I have a form. the first control on the form is a drop down box, called
business type. the two options available from this drop down box are:
- Ltd Company.
- Partnership.

now, my question. If 'ltd company' is selected from the dropdown box I
want the next control to be 'company registration number' - however, if
partnership was selected I want the next control to be 'partners'.

The idea is the form displays only those questions pertinent to the
particular case at hand. How do i do this?

The only way i can think of hand is to set the .visible properties of
the control's depeneding on the choices selected - but this isn't good
enough, for a start I would have to nest a series of controls on top of
each other on the form, which from a design standpoint isn't ideal.

How do i do this?

thanks!

Gary.
 
D

Douglas J Steele

One approach would be to use two different subforms, and make the
appropriate one active.

You wouldn't even need to have both loaded: you can have an empty subform
container on your form, and set its SourceObject property to point to the
appropriate form once you know which form that is.
 
B

Brendan Reynolds

One alternative would be to change the ControlSource property of the
control, and the Caption of its associated label. This could get messy,
though - you may also need to change many other properties, e.g. Format,
Input Mask, event properties, etc.

Private Sub Combo6_AfterUpdate()
If Me.Combo6 = "one" Then
Me.Text8.ControlSource = "TestText"
Me.Label9.Caption = "Test Text"
Else
Me.Text8.ControlSource = "TestTime"
Me.Label9.Caption = "Test Time"
End If
End Sub

Perhaps it might be easer to create two subforms, one for limited companies
and one for partnerships, each containing only the relevant controls. Then
just switch the SourceObject property ...

Private Sub Combo6_AfterUpdate()
If Me.Combo6 = "one" Then
Me.NameOfSubformControl.SourceObject = "frmLtdCompany"
Else
Me.NameOfSubformControl.SourceObject = "frmPartnership"
End If
End Sub
 
Top