Hi,
I've got an Access 2000 database that I need to finish in the next two hours. I've got a problem with a piece of my code, which is strange because it seems identical to the Microsoft knowledgebase example.
This code runs in Form_Open. It breaks on the line in red with error 7777 ("You've used the ListIndex property incorrectly".
lstAttendance is a listbox (Multiselect is set to None) in the current form.
Form_frmActivityEntry.LstAttendance is another listbox in a different form (also not Multiselect).
If Not IsNull(Form_frmActivityEntry.LstAttendance.Value) Then
'see if there's a corresponding attendance record for
'that student.
lngStudentID = _
Form_frmActivityEntry.LstAttendance.Column(3)
If LstAttendance.ListCount >= 1 Then
LstAttendance.ListIndex = 0
For i = 0 To LstAttendance.ListCount - 1
'If so, select that attendance record in the
'listbox and set to edit.
If LstAttendance.Column(6) = lngStudentID Then
SetAddUpdate True
Exit For
End If
If i < LstAttendance.ListCount - 1 Then
LstAttendance.ListIndex = _
LstAttendance.ListIndex + 1
End If
Next i
End If
'Even if no corresponding attendance record is found,
'set cboStudentID drop-down to currently selected student
'for adding.
cboStudentID.Value = lngStudentID
End If
What am I doing wrong??
TIA! Katie
Hi! I'm currently studying the COM+ programming model. Hopefully YOU'RE having fun, which would make one of us..
I've got an Access 2000 database that I need to finish in the next two hours. I've got a problem with a piece of my code, which is strange because it seems identical to the Microsoft knowledgebase example.
This code runs in Form_Open. It breaks on the line in red with error 7777 ("You've used the ListIndex property incorrectly".
lstAttendance is a listbox (Multiselect is set to None) in the current form.
Form_frmActivityEntry.LstAttendance is another listbox in a different form (also not Multiselect).
If Not IsNull(Form_frmActivityEntry.LstAttendance.Value) Then
'see if there's a corresponding attendance record for
'that student.
lngStudentID = _
Form_frmActivityEntry.LstAttendance.Column(3)
If LstAttendance.ListCount >= 1 Then
LstAttendance.ListIndex = 0
For i = 0 To LstAttendance.ListCount - 1
'If so, select that attendance record in the
'listbox and set to edit.
If LstAttendance.Column(6) = lngStudentID Then
SetAddUpdate True
Exit For
End If
If i < LstAttendance.ListCount - 1 Then
LstAttendance.ListIndex = _
LstAttendance.ListIndex + 1
End If
Next i
End If
'Even if no corresponding attendance record is found,
'set cboStudentID drop-down to currently selected student
'for adding.
cboStudentID.Value = lngStudentID
End If
What am I doing wrong??
TIA! Katie
Hi! I'm currently studying the COM+ programming model. Hopefully YOU'RE having fun, which would make one of us..