Filter field

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;
 
O

Ofer Cohen

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
 
D

Douglas J. Steele

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

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