Hello,
I have a comboBox in a form. The combobox is populates in the code below;
What I am trying to do now is have a user select an item from the combobox, and at the afterupdate event, filter the form by the field in the combobox, and the value that is in that field.
So for example, if the user selects "Salary" from the combobox, then the form is filtered by the Field "Salary" for whatever value is currently in the field "Salary." I have tried to do this but I keep getting the syntax wrong - I am not sure how to reference a field name through the combobox.
I know this is horribly wrong but here's what I've been playing with;
I have a comboBox in a form. The combobox is populates in the code below;
Code:
Private Sub cboFields_Enter()
Dim oRS As DAO.Recordset, i As Integer
Set oRS = Me.RecordsetClone
cboFields.RowSource = ""
For i = 1 To oRS.Fields.Count - 1
cboFields.AddItem oRS.Fields(i).Name
Next i
End Sub
What I am trying to do now is have a user select an item from the combobox, and at the afterupdate event, filter the form by the field in the combobox, and the value that is in that field.
So for example, if the user selects "Salary" from the combobox, then the form is filtered by the Field "Salary" for whatever value is currently in the field "Salary." I have tried to do this but I keep getting the syntax wrong - I am not sure how to reference a field name through the combobox.
I know this is horribly wrong but here's what I've been playing with;
Code:
Private Sub cboFields_AfterUpdate()
DoCmd.ApplyFilter Me.Name, "[" & cboFields.Value & "]" & "Like & cboFields"
End Sub