Niranalayo,
Let's follow the code.
You state about the number of groups. That seems like NoG, but it isn't. As an example, take a situation with 2 students. Coding starts with NoG = 1. Until-oop is executed at least once. If-condition, however, isn't true: 2/1 = 2 < 20. So NoG stays 1 and there is no record put into the recordset. But there is a group. In fact, there seems to always be one record less than the value of NoG. The solution could be to write one record outside the loop. Unless, of course, NoS = 0: no students, no group. Your current code doesn't make a difference between 0 and 1, and that seems wrong to me.
Seems like you have to redo the logic a little bit.
Hope this helps.
Kees
Hello everybody,
I am trying to divide students into tutor groups, the number of students in each tutor group must not be more than 20 but can be less than 20. I r=tried to devive an algorithm but it does not fully work. e.g for 75 students it is giving me 3 groups instead of 4. This is the code I have. Is there anything wrong with it?
Private Sub Tutor_Group_no_Click()
Dim NoG, NoS
Dim rstut As New ADODB.Recordset
rstut.Open ("select * from tblTutor_Group"), CurrentProject.Connection, adOpenKeyset, adLockOptimistic
NoS = DCount("Student_Id", "Query_Computing_and_Information_Systems")
NoG = 1
Do Until (NoS / NoG) <= 20
If (NoS / NoG) > 20 Then
NoG = NoG + 1
rstut.AddNew
rstut("Course_Id") = 1
rstut.Update
End If
Loop
MsgBox "Done"
End Sub
Please can anybody help ?

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic