R
Richard Hollenbeck
The value of the second list box properly cascades on the value of the first
one as far as putting data into the second list box, but when I click on a
student without a value for the second list box it doesn't erase the value
from the previous student. I'm wondering what I'm doing wrong.
Here's the code:
Private Sub lstStudents_AfterUpdate()
On Error GoTo Err_lstStudents_AfterUpdate
Dim StrSQL As String
Dim dbStudents As DAO.Database
Dim rsStudents As DAO.Recordset
StrSQL = "SELECT tblExtraCredit.activityDescription AS Activity FROM
tblExtraCredit INNER JOIN tblExraCreditScores ON tblExtraCredit.ID =
tblExraCreditScores.ID WHERE tblExraCreditScores.studentID = " &
lstStudents.Column(0)
Set dbStudents = CurrentDb()
Set rsStudents = dbStudents.OpenRecordset(StrSQL, dbOpenDynaset)
rsStudents.MoveFirst
Set lstActivities.Recordset = rsStudents
' The following command (lstActivities.Requery) is intended
' to empty the lstActivities list box if a record is blank.
' However, it doesn't work. If I click on a student's name
' where there is no extra credit activity
' the lstActivities listbox will remain blank. Once I click
' on a student that DOES have scores
' the activity will appear in the list box. But then when
' I click on a student with no Extra
' Credit activity the list box will STILL SHOW the
' data from the previous student.
lstActivities.Requery ' This isn't working
'rsStudents.Close (disabled because it's causing problems)
'dbStudents.Close (disabled because it's causing problems)
txtScore.Enabled = True
Exit_lstStudents_AfterUpdate:
Exit Sub
Err_lstStudents_AfterUpdate:
Call myErrorHandler(Err.Number, Err.Description, Err.Source)
Resume Exit_lstStudents_AfterUpdate
End Sub
one as far as putting data into the second list box, but when I click on a
student without a value for the second list box it doesn't erase the value
from the previous student. I'm wondering what I'm doing wrong.
Here's the code:
Private Sub lstStudents_AfterUpdate()
On Error GoTo Err_lstStudents_AfterUpdate
Dim StrSQL As String
Dim dbStudents As DAO.Database
Dim rsStudents As DAO.Recordset
StrSQL = "SELECT tblExtraCredit.activityDescription AS Activity FROM
tblExtraCredit INNER JOIN tblExraCreditScores ON tblExtraCredit.ID =
tblExraCreditScores.ID WHERE tblExraCreditScores.studentID = " &
lstStudents.Column(0)
Set dbStudents = CurrentDb()
Set rsStudents = dbStudents.OpenRecordset(StrSQL, dbOpenDynaset)
rsStudents.MoveFirst
Set lstActivities.Recordset = rsStudents
' The following command (lstActivities.Requery) is intended
' to empty the lstActivities list box if a record is blank.
' However, it doesn't work. If I click on a student's name
' where there is no extra credit activity
' the lstActivities listbox will remain blank. Once I click
' on a student that DOES have scores
' the activity will appear in the list box. But then when
' I click on a student with no Extra
' Credit activity the list box will STILL SHOW the
' data from the previous student.
lstActivities.Requery ' This isn't working
'rsStudents.Close (disabled because it's causing problems)
'dbStudents.Close (disabled because it's causing problems)
txtScore.Enabled = True
Exit_lstStudents_AfterUpdate:
Exit Sub
Err_lstStudents_AfterUpdate:
Call myErrorHandler(Err.Number, Err.Description, Err.Source)
Resume Exit_lstStudents_AfterUpdate
End Sub