Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT: Help iterating through listbox

Status
Not open for further replies.

Katerine

Programmer
Mar 9, 2001
234
US
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..
 
Katerine,
It is way past your two hour deadline, however, I believe the ListIndex property is read only.

llosee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top