Filter from two combo boxes

  • Thread starter Thread starter Gary Hull
  • Start date Start date
G

Gary Hull

I have a form that I want to run a filter from the combination of 2 combo
Boxes.

Below you will find the code that I am trying to use.

I get the error message (Missing operator)

Me.Filter = ("fkTeacher = " & Me.cboTeacherLookup) & _
("fkClass = " & Me.cboClassLookup)

Thanks for your help
 
Gary said:
I have a form that I want to run a filter from the combination of 2 combo
Boxes.

Below you will find the code that I am trying to use.

I get the error message (Missing operator)

Me.Filter = ("fkTeacher = " & Me.cboTeacherLookup) & _
("fkClass = " & Me.cboClassLookup)

Thanks for your help

Gary,

According to Help: "The Filter property is a string expression
consisting of a WHERE clause without the WHERE keyword. "

Try using: (* the following should be on one line *)

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup) AND "fkClass = " &
Me.cboClassLookup

HTH
 
SteveS said:
Gary,

According to Help: "The Filter property is a string expression
consisting of a WHERE clause without the WHERE keyword. "

Try using: (* the following should be on one line *)

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup) AND "fkClass = " &
Me.cboClassLookup

HTH

Oops, missed it by that much (one parenthesis).

Make that:

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup AND "fkClass = " &
Me.cboClassLookup
 
Make that:

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup AND "fkClass = " &
Me.cboClassLookup

I am getting a Type Mismatch error with this Code

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup AND "fkClass = " &
Me.cboClassLookup


fkTeacher is Long
fkClass is long
Key’s on the combo boxes are AutoNumbers

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup (works)
Me.Filter = "fkClass Me.cboClassLookup (works)
 
I am getting a Type Mismatch error with this Code

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup AND "fkClass = " &

The AND needs to be *inside* the quotes, not outside:

Me.Filter = "fkTeacher = " & Me.cboTeacherLookup & " AND fkClass = "
& Me.cboClassLookup

Thus if fkTeacher is 312 and fkClass is 87, the filter string will be

fkTeacher = 312 AND fkClass = 87

Note that the blank between " and AND is important - otherwise you'ld
get fkTeacher = 312AND

which will not be a valid value!
 
Gary said:
Thanks John, Worked like a charm

Gary,

Sorry for the typo. I had a problem between the keyboard and the chair
due to trying to handle errors raised by the wife sub-routine; it ended
up taking 100% processor time. The syntax checker was taken off line....

Good thing people are checking answers twice (or more).
 
Back
Top