Qualified Names for A Form Filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to apply a filter to a form. I want the filter to refernce the value of a feld in a query. The filter string is supposed to be like a WHERE clause without the word WHERE, but I don't know how to fully qualify the name of the field in the query so that Access knows what I'm talking about - it keeps putting up the text I type in asking for its value

For example, I have form1 based on table1 with a field tfield1. I also have query1 that has a field qfield1. I want to display all of the records for table1 where tfield1 has a value that exists in the qfield1 of query1
I try thi

Me.Filter = " table1![tfield1] = query1![qfield1]
and I get a message box asking for the value of "query1.qfield1

I've tried to be more explicit by usin
Me.Filter = "table1![tfield1] = QueryDefs("query1").Fields("qfield1"
and many more permutations of using parentheses and quotes and such but I keep getting asked for the value of whatever I have typed on the right side of the equals sign. I must not be expressing the fully qualified name correctly but I can't find the right syntax

Thanks for the help
Dav
 
Since query1 is not part of your original definition of the recordset, you
can't use a simple equals comparison like that.

You might be able to use something like this:
[table1.[tfield1] IN SELECT [qfield1] FROM query1

I've also never seen bangs used in WHERE Clauses, so I'd suggest dots.

HTH
- Turtle

Dave Lerman said:
I am trying to apply a filter to a form. I want the filter to refernce the
value of a feld in a query. The filter string is supposed to be like a WHERE
clause without the word WHERE, but I don't know how to fully qualify the
name of the field in the query so that Access knows what I'm talking about -
it keeps putting up the text I type in asking for its value.
For example, I have form1 based on table1 with a field tfield1. I also
have query1 that has a field qfield1. I want to display all of the records
for table1 where tfield1 has a value that exists in the qfield1 of query1.
I try this

Me.Filter = " table1![tfield1] = query1![qfield1]"
and I get a message box asking for the value of "query1.qfield1"

I've tried to be more explicit by using
Me.Filter = "table1![tfield1] = QueryDefs("query1").Fields("qfield1")
and many more permutations of using parentheses and quotes and such but I
keep getting asked for the value of whatever I have typed on the right side
of the equals sign. I must not be expressing the fully qualified name
correctly but I can't find the right syntax.
 
Back
Top