SQL problem (1 Viewer)

sam1fletcher

Registered User.
Local time
Today, 05:17
Joined
Jan 28, 2013
Messages
40
hi

I have a problem with my query. the problem: i have a table of schools(tblschool) the table has a County feild which is text and 2 Y/N feild called HMC and GSA.
i want to be able to retreived records that are in a specific county and have one of these ticked. Simple rite! but the problem arrises when a school has both ticked as they dont come up in either search. the search has to be both HMC and GSA in a county to get that school.

my code so far
SELECT *
FROM tblSchool
WHERE (((tblSchool.County)=Forms!frmSchoolSelect!County) And (((tblSchool.HMC)=Forms!frmSchoolSelect!HMC) or ((tblSchool.GSA)=Forms!frmSchoolSelect!GSA)));

but this seems to retreive pretty much every school in a county. not just a hmc or a gsa
 

sxschech

Registered User.
Local time
Yesterday, 21:17
Joined
Mar 2, 2010
Messages
801
If you are saying that the items are ticked, I am assuming that you have a yes/no (check boxes) field in your table. The following should work.

Code:
SELECT *
FROM tblSchool
WHERE tblSchool.County=Forms!frmSchoolSelect!County 
And (tblSchool.HMC=TRUE or tblSchool.GSA=TRUE);
 

Users who are viewing this thread

Top Bottom