CheckBox.Visible = False

dawkirst

Registered User.
Local time
Today, 10:46
Joined
Sep 1, 2005
Messages
21
Greetings.

I have a ComboBox and a CheckBox on my form.

The ComboBox gets its values from a table called Colors.

I want the CheckBox's Visible property to turn False when the ComboBox has a certain value.

This is the code I used:

Code:
Private Sub Product_AfterUpdate()
If Combo75.Value = "W/Blue" Then Stripe.Visible = False
End If
End Sub

Combo75 is my ComboBox; Stripe is my CheckBox. (Excuse my bad VB basics please :o )

Any ideas?

Thanks ahead!
 
you will probably want to do it from the combobox afterupdate event., and call the combobox afterupdate from the Forms Current event so it updates it as you scroll through records.

If Combo75.Value = "W/Blue" Then
Stripe.Visible = False
else
Stripe.Visible = true
End If


HTH

Peter
 
Thanks, it worked.

However, I want the CheckBox's Visible property to turn False on four specific values (not only one.) The colors are W/Blue, W/Green, W/Brown, and W/Orange.

This code does not work. Only one color keeps toggling the Visible property:

Code:
Private Sub Combo75_BeforeUpdate(Cancel As Integer)

If Combo75.Value = "W/Green" Then
Stripe.Visible = False
Else
Stripe.Visible = True
End If

If Combo75.Value = "W/Blue" Then
Stripe.Visible = False
Else
Stripe.Visible = True
End If

If Combo75.Value = "W/Orange" Then
Stripe.Visible = False
Else
Stripe.Visible = True
End If

If Combo75.Value = "W/Brown" Then
Stripe.Visible = False
Else
Stripe.Visible = True
End If

End Sub

Neither this code. It gives me a mismatch error:

Code:
If Combo75.Value = "W/Green" Or "W/Blue" or "W/Brown" Or "W/Orange" Then
Stripe.Visible = False
Else
Stripe.Visible = True
End If

Can you help me here? Should I perhaps take out the "End If"s?
 
Try using a SELECT CASE clause with a Case Else for ircumstances where your checkbox is to stay visible


------------------------------------------------
Employ a teenager whilst he still knows everything
 
try
Code:
Select Case Combo75.Value
Case "W/Green"
    Stripe.Visible = False
Case "W/Blue"
    Stripe.Visible = False
Case "W/Orange"
    Stripe.Visible = False
Case "W/Brown"
    Stripe.Visible = False
Case Else
    Stripe.Visible = True
End Select

Peter
 
Or even...

Code:
Select Case Combo75.Value
  Case "W/Green", "W/Blue", "W/Orange", "W/Brown"
    Stripe.Visible = False
  Case Else
    Stripe.Visible = True
End Select
 

Users who are viewing this thread

Back
Top Bottom