没有表测试,只能大概给个代码,请自行调整,如果班级是整数型,记得不用单引号。
Dim dt2 As DataTable
Dim dr2 As DataRow
Dim bjs As String
cmd.CommandText = "select gID from {gradeInfo} where gradeName = '" & e.Form.Controls("cbcgInfo").value.trim() & "'"
dt = cmd.ExecuteReader()
dr = dt.DataRows(0)
cmd.CommandText = "select cID from {classInfo} where gID = " & dr("gID")
dt2 = cmd.ExecuteReader()
For Each dr As DataRow In dt2.DataRows
bjs = bjs & "'" & dr("班级") & "',"
Next
bjs = bjs.Trim(","c)
Tables("档案信息_studentInfo").Filter = " 班级 in (" & bjs & ")"