Set Subform Controls Visible Based on Combo

misscrf

Registered User.
Local time
, 20:15
Joined
Nov 1, 2004
Messages
158
On a subform I have a combo (cboType)

Based on the selection of that combo, I have certain controls on the form that should be visible and the rest false. I created a Case Select statement on the after update of that combo, to set the subform controls visible and invisible.

A couple of questions I have -

1) besides for after update of the combo, where else should I put this, to make sure that the form is always looking appropriately?:confused:

2) how do I handle null, i.e there is no record yet (so only the cboType combo should be visible):rolleyes:

3) How do ensure that during main form load, and navigation, this is form's controls visible status is updated?:o

4) While separate, and more of a layout thing, one of my choices only uses 1 date field and the comments field, while the others have a bunch of fields in use. How do I set the layout, so that when it is just the date field and comments field it doesn't have a huge space in the form (reserved for the invisible fields).:eek:


This is my current case select code, so you can see it:

Code:
Select Case Me.cboType

Case 1

Me.cboSubType.Visible = True
Me.dtDate1.Visible = True
Me.txtComments.Visible = True
Me.cboPerson1.Visible = False
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = False
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = False
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 2
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 3
Me.cboSubType.Visible = False
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = False
Me.cboPerson2.Visible = True
Me.cboPerson3.Visible = True
Me.dtDate2.Visible = False
Me.dtDate3.Visible = True
Me.txtNameSpec.Visible = True
Me.dtDate4.Visible = True
Me.cboPerson1Type.Visible = False
Me.cboPerson2Type.Visible = True
Me.cboPerson3Type.Visible = True

Case 4
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 5
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

End Select

Thanks for any help!!!
 
On a subform I have a combo (cboType)

Based on the selection of that combo, I have certain controls on the form that should be visible and the rest false. I created a Case Select statement on the after update of that combo, to set the subform controls visible and invisible.

A couple of questions I have -

1) besides for after update of the combo, where else should I put this, to make sure that the form is always looking appropriately?:confused:

2) how do I handle null, i.e there is no record yet (so only the cboType combo should be visible):rolleyes:

3) How do ensure that during main form load, and navigation, this is form's controls visible status is updated?:o

4) While separate, and more of a layout thing, one of my choices only uses 1 date field and the comments field, while the others have a bunch of fields in use. How do I set the layout, so that when it is just the date field and comments field it doesn't have a huge space in the form (reserved for the invisible fields).:eek:


This is my current case select code, so you can see it:

Code:
Select Case Me.cboType

Case 1

Me.cboSubType.Visible = True
Me.dtDate1.Visible = True
Me.txtComments.Visible = True
Me.cboPerson1.Visible = False
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = False
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = False
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 2
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 3
Me.cboSubType.Visible = False
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = False
Me.cboPerson2.Visible = True
Me.cboPerson3.Visible = True
Me.dtDate2.Visible = False
Me.dtDate3.Visible = True
Me.txtNameSpec.Visible = True
Me.dtDate4.Visible = True
Me.cboPerson1Type.Visible = False
Me.cboPerson2Type.Visible = True
Me.cboPerson3Type.Visible = True

Case 4
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

Case 5
Me.cboSubType.Visible = True
Me.dtDate1.Visible = False
Me.txtComments.Visible = True
Me.cboPerson1.Visible = True
Me.cboPerson2.Visible = False
Me.cboPerson3.Visible = False
Me.dtDate2.Visible = True
Me.dtDate3.Visible = False
Me.txtNameSpec.Visible = False
Me.dtDate4.Visible = False
Me.cboPerson1Type.Visible = True
Me.cboPerson2Type.Visible = False
Me.cboPerson3Type.Visible = False

End Select

Thanks for any help!!!

You will probably need to also use the On Current event of the form.

Code:
Private Sub Form_Current()

If Me.NewRecord Then

  ' call function/sub to set up for new record

Else
  
 ' call function/sub to set up for current record

End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom