我需要创建班级考试的位置 [英] I need to create class exam position

查看:58
本文介绍了我需要创建班级考试的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究访问数据库,需要根据他们在课堂上的分数给出每个学生的位置。


例如:

有5个班级有以下分数的学生:
学生 分数

学生A:32

学生B:78

学生C:90

学生D:90

学生E:21


我希望因此产生他们的位置:

Calss的学生位置

学生A:4

学生B:2

学生C:1

学生D:1

学生E:5


记下学生C和D之间的关系拜托。


谢谢。

I am working on access database and need to give each student position based on their score in class.

For example:
A class with 5 students with the following scores:
Student Score
Student A: 32
Student B: 78
Student C: 90
Student D: 90
Student E: 21

I wish to generate their position thus:
Student Position in Calss
Student A: 4
Student B: 2
Student C: 1
Student D: 1
Student E: 5

Take note of the tie between Student C and D please.

Thank you.

推荐答案

这里有一个解决方案


您可以按降序对最终成绩进行排序。我们称之为tblStudents,分为领域学生和学生分数和排名


创建表单和命令按钮。不要指定任何向导的东西,只需单击取消。


将命令按钮的名称属性更改为cmdRankStudents ...然后...转到事件并单击然后单击空白框的右侧并进入代码生成器...


输入以下代码:


Private Sub cmdRankStudents_Click()

On Error GoTo Err_cmdRankStudents_Click


DoCmd.SetWarnings False


''打开ADODB连接和记录集

Dim con As ADODB.Connection


Dim rsStudents as ADODB.Recordset



设置con = CurrentProject.Connection


设置rsStudents =新ADODB.Recordset


Dim X As Integer

X = 1


Dim Y As Integer

Dim Z as Integer


rsStudents.MoveFirst

Y = rsStudents.Fields(" StudentScore&quo t;)

rsStudents.Fields(" Ranking")= X

rsStudents.MoveNext

直到rsStudents.EOF


如果rsStudent.Fields(" StudentScore")= Y

rsStudents.AddNew

rsStudents.Fields(" Ranking")= X

rsStudents.MoveNext

rsStudents.Update

Else

Y = rsStudents.Fields(" StudentScore")

X = X + 1

rsStudents.AddNew

rsStudents.Fields(" Ranking")= X

rsStudents.Update

rsStudents.MoveNext

EndIf


循环


' '如果你希望学生排名跳过,如果你有两个排名为1然后转到3,只需使用Z变量并通过在if语句的两种可能性(Z = Z + 1)下添加并因此使用它作为计数器=第二个if下的X + Z.声明将是3如果有一个平局1


''现在关闭一切(连接和记录集)


rsStudents.Close


设置con = Nothing


设置rsStudents = Nothing


DoCmd.SetWarnings True

Exit_cmdRankStudents_Click:

退出Sub


Err_cmdRankStudents_Click:

MsgBox Err.Description

恢复退出_cmdRank学生_点击


结束子


我认为这应该像魅力一样...让我知道你有没有问题:)


干杯

Kosm?s


ps如果你碰巧在我的学校教书...布兰迪斯大学...我最好把你的课程拿到X = 1排名:) lol
here''s one solution

You could sort their final grades in descending order. We''ll call this tblStudents which is divided into fields Students and StudentScore and Ranking

Create a form and a command button. Don''t assign any of the wizard stuff but just click cancel.

Change the name properties of the command button to cmdRankStudents...then...go to events and on click and click on the right hand side of the blank white box and go into the code builder...

put in the following code:

Private Sub cmdRankStudents_Click()
On Error GoTo Err_cmdRankStudents_Click

DoCmd.SetWarnings False

''Opening ADODB connections and record sets
Dim con As ADODB.Connection

Dim rsStudents As ADODB.Recordset


Set con = CurrentProject.Connection

Set rsStudents = New ADODB.Recordset

Dim X As Integer
X = 1

Dim Y As Integer
Dim Z As Integer

rsStudents.MoveFirst
Y = rsStudents.Fields("StudentScore")
rsStudents.Fields("Ranking") = X
rsStudents.MoveNext
Do Until rsStudents.EOF

If rsStudent.Fields("StudentScore") = Y
rsStudents.AddNew
rsStudents.Fields("Ranking") = X
rsStudents.MoveNext
rsStudents.Update
Else
Y = rsStudents.Fields("StudentScore")
X = X + 1
rsStudents.AddNew
rsStudents.Fields("Ranking") = X
rsStudents.Update
rsStudents.MoveNext
EndIf

Loop

'' if you want student ranking to skip if you have two rankings of 1 then go to 3, just use the Z variable and use it as a counter by adding under both possibilities of the if statement (Z = Z+1) and therefore X = X + Z under the second if statement would be 3 if there was a tie for 1

'' now close everything up (connections and recordsets)

rsStudents.Close

Set con = Nothing

Set rsStudents = Nothing

DoCmd.SetWarnings True

Exit_cmdRankStudents_Click:
Exit Sub

Err_cmdRankStudents_Click:
MsgBox Err.Description
Resume Exit_cmdRankStudents_Click

End Sub


And I think that should work like a charm...let me know if you have any problems :)

Cheers
Kosm?s

p.s. if you happen to teach at my school...Brandeis University...I better take your class and get that X=1 ranking :) lol


澄清...你应该排序字段,学生成绩,降序...

如果您不熟悉访问权限并且不知道如何访问onclick事物,您可以将其创建为模块并运行确保它有效的模块......如果它不起作用,请告诉我,但如果只是查看DoCmd.RunModule,我肯定会有一些地方会告诉你该怎么做。


不久前我是新来的......所以我清楚地记得你经历的事情大声笑......这,其实是第一次我直接回答了某人的问题:)
to clarify...you should sort the field, studentgrades, in descending order...
If you are not familiar with access and don''t know how to get to the onclick thing, you can just create this as a module and run the module to make sure it works...if it doesn''t work let me know but if it does just look up DoCmd.RunModule and I''m sure there will be some place that will show you what to do from there.

I was new to access not too long ago... so I vividly remember what you''re going through lol..... this, in fact, is the first time I''ve directly answered someone''s question :)



我正在研究访问数据库并需要给每个学生的位置根据他们在课堂上的分数。


例如:

A级有5名学生,分数如下:
学生 分数

学生A:32

学生B :78

学生C:90

学生D:90

学生E:21


我希望如此产生他们的立场:

学生在课堂上的位置

学生A:4

学生B:2

学生C:1

学生D:1

学生E:5


记下学生C之间的关系和D请。


谢谢。
I am working on access database and need to give each student position based on their score in class.

For example:
A class with 5 students with the following scores:
Student Score
Student A: 32
Student B: 78
Student C: 90
Student D: 90
Student E: 21

I wish to generate their position thus:
Student Position in Class
Student A: 4
Student B: 2
Student C: 1
Student D: 1
Student E: 5

Take note of the tie between Student C and D please.

Thank you.



假设一个名为[tblScore]的表带有[StudentID]字段(数字)和[Score]字段(数字),那么你需要这样的东西(NB考试的标准序数定位系统是高于+ 1的条目数的计数:

Assuming a table called [tblScore] with a [StudentID] field (numeric) and a [Score] field (numeric) then you would need something like this (NB the standard ordinal positioning system for exams is a count of the number of entries that are higher + 1) :

展开 | 选择 | Wrap | 行号


这篇关于我需要创建班级考试的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆