"Visible" problem

  • Thread starter Thread starter dcasado
  • Start date Start date
D

dcasado

Guest
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.
 
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:

Code:
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).]
 
Thanks for that
 

Users who are viewing this thread

Back
Top Bottom