Another one for you geniuses,
Im trying to assign students to tutors until a tutors chamber is full. I have tried the code below but it wont let me update the space a tutor has left in their chamber. Its says "cannot update: database or object is read only". Does anyone know how i can get around this please??
Set rs = db.OpenRecordset("Select * from [tblWorking]")
Set rs2 = db.OpenRecordset("Select [tblTutor].TU_CODE, [tblTutor].TU_CHAMBER_SIZE, [tblTutor].TU_DP_NO, [TU_CHAMBER_SIZE]-Count([STU_TU_CODE]) AS space from ([tblTutor] inner join [tblStudents] on [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE) group by tblTutor.TU_CODE, tblTutor.TU_CHAMBER_SIZE,[tblTutor].TU_DP_NO, tblStudents.STU_TU_CODE having [tblTutor].TU_DP_NO = 57 ")
Do While Not rs.EOF
If IsNull(rs("STU_TU_CODE")) Then
If rs2("space") > 0 Then
rs.Edit
rs!STU_TU_CODE = rs2("TU_CODE")
rs.Update
rs2("space") = (rs2("space") - 1)
rs.MoveNext
Else
rs2.MoveNext
End If
End If
Loop
Im trying to assign students to tutors until a tutors chamber is full. I have tried the code below but it wont let me update the space a tutor has left in their chamber. Its says "cannot update: database or object is read only". Does anyone know how i can get around this please??
Set rs = db.OpenRecordset("Select * from [tblWorking]")
Set rs2 = db.OpenRecordset("Select [tblTutor].TU_CODE, [tblTutor].TU_CHAMBER_SIZE, [tblTutor].TU_DP_NO, [TU_CHAMBER_SIZE]-Count([STU_TU_CODE]) AS space from ([tblTutor] inner join [tblStudents] on [tblTutor].TU_CODE = [tblStudents].STU_TU_CODE) group by tblTutor.TU_CODE, tblTutor.TU_CHAMBER_SIZE,[tblTutor].TU_DP_NO, tblStudents.STU_TU_CODE having [tblTutor].TU_DP_NO = 57 ")
Do While Not rs.EOF
If IsNull(rs("STU_TU_CODE")) Then
If rs2("space") > 0 Then
rs.Edit
rs!STU_TU_CODE = rs2("TU_CODE")
rs.Update
rs2("space") = (rs2("space") - 1)
rs.MoveNext
Else
rs2.MoveNext
End If
End If
Loop