context sensitive forms

  • Thread starter Thread starter Gary
  • Start date Start date
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.
 
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.
 
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
 

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

Similar Threads

Access Form Refresh 1
combo box locked 4
go to control in access 2007 1
link form fields ?? 1
Access 2007 - Table A lookup values based on Table B 1
combo box 1
Drop Down in Form View 3
Lookup restrictions 3

Back
Top