Filter field

  • Thread starter Thread starter Raul Sousa
  • Start date Start date
R

Raul Sousa

I have a form with several fields. Two of them named Categoria and Familia.
Every Familia has one or more categoria.
I would like to show only the categoria for the selected familia.
So, I have this code to perform the selection:
SELECT Artigos.Categoria FROM Artigos WHERE (((Artigos.Familia)= [Familia]))
GROUP BY Artigos.Categoria;
It is not working. In this way it shows every categoria.

It woks if I specify the familia, like
SELECT Artigos.Categoria FROM Artigos WHERE (((Artigos.Familia)= “Livrosâ€))
GROUP BY Artigos.Categoria;
 
Look at this link on "Limit content of combo/list boxes"

http://www.mvps.org/access/forms/frm0028.htm

If you are using code, then you need to move the text box in the form out
side the string, like:

"SELECT Artigos.Categoria FROM Artigos WHERE (((Artigos.Familia)= " &
Me.[Familia] & ")) GROUP BY Artigos.Categoria"

Or, if you are filtering using the RowSource directly without code, you need
to provide the full path

SELECT Artigos.Categoria FROM Artigos WHERE (((Artigos.Familia)=
Forms![MainFormName]![Familia])) GROUP BY Artigos.Categoria
 
SELECT Artigos.Categoria FROM Artigos
WHERE (((Artigos.Familia)= Forms![NameOfForm]![Familia]))
GROUP BY Artigos.Categoria;
 
Back
Top