VBA for Form.Filter

  • Thread starter Christopher Glaeser
  • Start date
C

Christopher Glaeser

I want a command button to filter a form by comparing two combo boxes for
equality. I found some code from an example that is similar (the example
compared a bound text box to a combo box). In my database, Combo8 is bound
to a table and cboChooseColor is unbound and used to set the filter value.

Form_frmDemoFilter.Form.Filter = "Combo8='" & Me.cboChooseColor & "'"
Form_frmDemoFilter.Form.FilterOn = True

Suggestions for the correct syntax for the comparison will be greatly
appreciated.

Best,
Christopher
 
K

Ken Snell [MVP]

A filter statement must use a field that is in the form's recordsource, not
a control on the form. Thus, replace Combo8 in your expression with the name
of the field to which it's bound.
 
C

Christopher Glaeser

A filter statement must use a field that is in the form's recordsource, not
a control on the form. Thus, replace Combo8 in your expression with the
name
of the field to which it's bound.

Bingo! Many thanks. - Christopher
 

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


Top