Okay, this was the query I was pointing you too earlier...
S = "SELECT COUNT(*) AS THECOUNT FROM Table1 WHERE class = '" & Trim(Text1.Text) & "'"
You just need to adjust which table it points to (table1 vs. table2) and which field it points to.
Good Luck