|
以下代码为点击后生成一个查询:
Private Sub Command0_Click()
Dim dbsCurrent As Database, qryTest As QueryDef, gshiqx As String, gshinj As String, gshibj As String
Set dbsCurrent = CurrentDb
Set qryTest = dbsCurrent.QueryDefs("Gims_st_cj_考试成绩_查询_排名")
gshiqx = DCount("*", "st_cj_考试成绩录入修改表", "[总分]>" & [总分]) + 1
gshinj = DCount("*", "st_cj_考试成绩录入修改表", "[区码]='" & [区码] & "' and [总分]>" & [总分]) + 1
gshibj = DCount("*", "st_cj_考试成绩录入修改表", "[区码]='" & [区码] & "' and [班级]='" & [班级] & "' and [总分]>" & [总分]) + 1
qryTest.SQL = "SELECT ID, 区码,校区,信息编号,姓名,年级,年级代码,班级,班级代码,学期,考试性质,考试时间,语文,数学,英语,物理,化学,生物,政治,历史,地理,信息,通用,总分 " _
& "," & gshiqx & " AS 全校排名, " & gshinj & " AS 年级排名, " & gshibj & " AS 班级排名,备注,录入修改,录入修改时间,语文1,数学1,英语1,物理1,化学1,生物1,政治1 " _
& ", 历史1,地理1,信息1,通用1 FROM st_cj_考试成绩录入修改表;"
End Sub
其中:gshiqx 为全校排名公式,gshinj 为按年级排名公式,gshibj为按班级排名公式;
本人用意:通过一个组合框可选择 按总分、语文、数学.....不同字段 排名。但以上代码执行时错误,请各位帮助订正。
另:通过组合框改变排名字段时,公式中 如何替换 [总分]。
谢谢!!! |
|