Filter using a combo box

B

bobw

I have an unbound combo box "cmbfilter" located in the form header that I
want to use to filter open and closed records. My row source type is
table/query and my row source is log_status_qry. I have a cmbo box
(cmbstatus) in the detail of the form that shows me the current "status" of
the record, "Open" or "Closed". I have read all that I can on the filter
command in the afterupdate procedure but I cannot get my filter to work. I
guess that I just don't understand where my problem is. Here is my code:

Private Sub cmbfilter_AfterUpdate()
Me.Filter = "status = " & Me.cmbfilter
Me.cmbstatus.Requery
Me.FilterOn = True
End Sub

TIA,
Bob W.
 
A

Allen Browne

If you open your table in design view, what is the Data Type of the Status
field?

If it is Text (not Number or Yes/No), you need extra quotes:
Me.Filter = "status = """ & Me.cmbfilter & """"
 

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