SELECT COUNT(category="H") FROM (alias11) WHERE b.date=date .and. year(date) = thisform.text1.Value INTO CURSOR cTemp *** This select must raise you an error because there is no B. defined *** but as I sayd just make it work as you want *** then remove INTO CURSOR .... surround it with brackets and copy and paste it into the first SELECT. *** It is a good Idea to Give a name to that Name i.e (SELECT....) AS CategoryCount.