Help with comboboxes and checkboxes

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

I have a bunch of checkboxes and comboboxes. I want a combobox to have values
in it only when the corresponding check box is checked. I tried this:
Private Sub cmbCluster_Click()
If chkCluster.Value = True Then
Me.cmbCluster.RowSource = "SELECT DISTINCT [CLUSTER] FROM
[tblConstruction_Tracker] ORDER BY [CLUSTER]"
ElseIf chkCluster.Value = False Then
Me.cmbCluster.RowSource = ""
End If
End Sub

Private Sub cmbConstr_Mgr_Click()
If chkConstr_Mgr.Value = True Then
Me.cmbConstr_Mgr.RowSource = "SELECT DISTINCT [CONSTR MGR] FROM
[tblConstruction_Tracker] ORDER BY [CONSTR MGR]"
Else
Me.cmbConstr_Mgr.RowSource = ""
End If
End Sub

but is don't work. Right now the combo boxes have values in them with, or
without the checkboxes checked. Thanks for the help.
 
First, there is no need for the ElseIf , Else will do

If chkCluster.Value = True Then
Me.cmbCluster.RowSource = "SELECT DISTINCT [CLUSTER] FROM
[tblConstruction_Tracker] ORDER BY [CLUSTER]"
Else
Me.cmbCluster.RowSource = ""
End If

About your question, if the combo's are unbound, then remove the value from
them
Something like
Me.cmbCluster.RowSource = ""
Me.cmbCluster = Null

If the combo's are bounded, then remove the ControlSource
Instead of Me.cmbCluster = Null
Write
Me.cmbCluster.ControlSource = ""
 
The comboboxes are unbounded and they don't have any values.

Ofer Cohen said:
First, there is no need for the ElseIf , Else will do

If chkCluster.Value = True Then
Me.cmbCluster.RowSource = "SELECT DISTINCT [CLUSTER] FROM
[tblConstruction_Tracker] ORDER BY [CLUSTER]"
Else
Me.cmbCluster.RowSource = ""
End If

About your question, if the combo's are unbound, then remove the value from
them
Something like
Me.cmbCluster.RowSource = ""
Me.cmbCluster = Null

If the combo's are bounded, then remove the ControlSource
Instead of Me.cmbCluster = Null
Write
Me.cmbCluster.ControlSource = ""


--
Good Luck
BS"D


Ayo said:
I have a bunch of checkboxes and comboboxes. I want a combobox to have values
in it only when the corresponding check box is checked. I tried this:
Private Sub cmbCluster_Click()
If chkCluster.Value = True Then
Me.cmbCluster.RowSource = "SELECT DISTINCT [CLUSTER] FROM
[tblConstruction_Tracker] ORDER BY [CLUSTER]"
ElseIf chkCluster.Value = False Then
Me.cmbCluster.RowSource = ""
End If
End Sub

Private Sub cmbConstr_Mgr_Click()
If chkConstr_Mgr.Value = True Then
Me.cmbConstr_Mgr.RowSource = "SELECT DISTINCT [CONSTR MGR] FROM
[tblConstruction_Tracker] ORDER BY [CONSTR MGR]"
Else
Me.cmbConstr_Mgr.RowSource = ""
End If
End Sub

but is don't work. Right now the combo boxes have values in them with, or
without the checkboxes checked. Thanks for the help.
 

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


Back
Top