S
Secret Squirrel
I'm trying to run this code below but I'm not sure how to add "acComboBox" to
my code. Right now it's checking all my checkboxes via the "acCheckBox" but I
also need it to look at comboboxes as well. Is it as simple as adding "Or
acComboBox" on the Case line?
On Error Resume Next
Dim ctl As Control
Dim sSQL As String
Dim sWhereClause As String
Me.txtSQL = Null
'Initialize the Where Clause variable.
sWhereClause = " Where "
'Start the first part of the select statement.
sSQL = "select EmpName from qryARSkills "
'Loop through each control on the form to get its value.
For Each ctl In Me.Controls
With ctl
'The only Control you are using is the check box. However, you
can add as many types of controls as you want.
Select Case .ControlType
Case acCheckBox
'This is the function that actually builds the clause.
If (.Value) Then
If sWhereClause = " Where " Then
sWhereClause = sWhereClause &
BuildCriteria(.Name, dbBoolean, .Value)
Else
sWhereClause = sWhereClause & " And " &
BuildCriteria(.Name, dbBoolean, .Value)
End If
End If
End Select
End With
Next ctl
'Set the listbox rowsource equal to the new select statement.
Me.txtSQL = sSQL & sWhereClause
Me.EmpList.RowSource = Me.txtSQL
Me.EmpList.Requery
my code. Right now it's checking all my checkboxes via the "acCheckBox" but I
also need it to look at comboboxes as well. Is it as simple as adding "Or
acComboBox" on the Case line?
On Error Resume Next
Dim ctl As Control
Dim sSQL As String
Dim sWhereClause As String
Me.txtSQL = Null
'Initialize the Where Clause variable.
sWhereClause = " Where "
'Start the first part of the select statement.
sSQL = "select EmpName from qryARSkills "
'Loop through each control on the form to get its value.
For Each ctl In Me.Controls
With ctl
'The only Control you are using is the check box. However, you
can add as many types of controls as you want.
Select Case .ControlType
Case acCheckBox
'This is the function that actually builds the clause.
If (.Value) Then
If sWhereClause = " Where " Then
sWhereClause = sWhereClause &
BuildCriteria(.Name, dbBoolean, .Value)
Else
sWhereClause = sWhereClause & " And " &
BuildCriteria(.Name, dbBoolean, .Value)
End If
End If
End Select
End With
Next ctl
'Set the listbox rowsource equal to the new select statement.
Me.txtSQL = sSQL & sWhereClause
Me.EmpList.RowSource = Me.txtSQL
Me.EmpList.Requery