View Full Version : "Visible" problem


dcasado
05-10-2002, 03:17 AM
I have a combo box with two different options, each value corresponds to a certain text box(both invisble). How is it possible to select the first value and have the first text box visible. And the same with the second value.

Graham T
05-10-2002, 04:57 AM
dcasado

You could try the following code, which is attached to the On Current event of your form and the After Update event of your combo box.

The example is using a combo box called cboFormat and 2 text boxes (txtCD and txtMiniDisc) with their properties set to Visible (No). The combo box contains the values of CD and MiniDisc:


Private Sub Form_Current()
'If cboFormat is null do not show text boxes
If IsNull(cboFormat) Or Me.Format = "" Then
Me.txtCD.Visible = False
Me.txtMini.Visible = False
End If
'If cboFormat contains a value show appropriate text box
If Me.cboFormat.Value = "CD" Then
Me.txtCD.Visible = True
Me.txtMini.Visible = False
Else
If Me.cboFormat.Value = "MiniDisc" Then
Me.txtMini.Visible = True
Me.txtCD.Visible = False
End If
End If
End Sub

--------------------------------------

Private Sub cboFormat_AfterUpdate()
'If cboFormat is null do not show text boxes
If IsNull(cboFormat) Or Me.Format = "" Then
Me.txtCD.Visible = False
Me.txtMini.Visible = False
End If
'If cboFormat contains a value show appropriate text box
If Me.cboFormat.Value = "CD" Then
Me.txtCD.Visible = True
Me.txtMini.Visible = False
Else
If Me.cboFormat.Value = "MiniDisc" Then
Me.txtMini.Visible = True
Me.txtCD.Visible = False
End If
End If
End Sub

HTH

Graham

[This message has been edited by Graham T (edited 05-10-2002).]

dcasado
05-10-2002, 08:42 AM
Thanks for that