Combo Box Filtering Issues

G

Guest

I am trying to filter a form to only display the records that match what is
listed in the combo box. For the most part it is working. My issue right
now is that when i make my selection in my combo box a pop-up screen appears
saying "Enter Parameter Value" then below it gives the value of my selection
and then also gives a box to enter in a value. The only way that it will
pull up the records is if I type in the same value as what i selected in the
combo box. What is wrong with my code?

The code i am using is:
Private Sub cboDescriptor_AfterUpdate()
Dim strWhere As String

If Me.Dirty Then 'Save any edits
Me.Dirty = False
End If

With Me.cboDescriptor
If IsNull(.Value) Then 'Show all records
If Me.FilterOn Then
Me.FilterOn = False
End If
Else
strWhere = "[Descriptor]= " & .Value
Me.Filter = strWhere
Me.FilterOn = True
End If
End With
End Sub
 
G

Guest

If the field [Descriptor] is a not a numeric field, then the syntax is
incorrect.
strWhere = "[Descriptor]= " & .Value
For a text field, it should be
strWhere = "[Descriptor]= '" & .Value & "'"
 
G

Guest

This worked perfect. Thank you so much!

Klatuu said:
If the field [Descriptor] is a not a numeric field, then the syntax is
incorrect.
strWhere = "[Descriptor]= " & .Value
For a text field, it should be
strWhere = "[Descriptor]= '" & .Value & "'"

MimiSD said:
I am trying to filter a form to only display the records that match what is
listed in the combo box. For the most part it is working. My issue right
now is that when i make my selection in my combo box a pop-up screen appears
saying "Enter Parameter Value" then below it gives the value of my selection
and then also gives a box to enter in a value. The only way that it will
pull up the records is if I type in the same value as what i selected in the
combo box. What is wrong with my code?

The code i am using is:
Private Sub cboDescriptor_AfterUpdate()
Dim strWhere As String

If Me.Dirty Then 'Save any edits
Me.Dirty = False
End If

With Me.cboDescriptor
If IsNull(.Value) Then 'Show all records
If Me.FilterOn Then
Me.FilterOn = False
End If
Else
strWhere = "[Descriptor]= " & .Value
Me.Filter = strWhere
Me.FilterOn = True
End If
End With
End Sub
 

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

Top