VB6, MS Access 2000
Hi! Would you please help me with the following problem?
Let's just say there's no problem with connecting the database form,
I'm trying to add new records using data from a listbox that is not 'placed' on top at the moment.
Destination table
Name: History
Fields: EventID and StudentID
Listbox on frmParticipants: lstParticipants, lstTIC
I want to 'keep adding' new records on to the database, each record consists of the same EventID (from the currently '___.Show 1'-ed form) but different StudentID, depending on what's stored in the itemdata part of the list.
Here's the code:E.g. What I should be seeing in the database:
EventID StudentID
12345 23456
12345 34567
12345 45678
54321 33546
.
.
.
etc.
When I ran this, the following error is displayed:Code:mrsHistory.Open "History", gcnCDC, adOpenStatic, adLockOptimistic, adCmdTable mrsHistory.AddNew With mrsHistory For Counter = 0 To frmParticipants.lstParticipants.ListCount - 1 !EventID = Val(txtEventID) !StudentID = frmParticipants.lstStudents.ItemData(Counter) '(frmParticipants.lstStudents.List(Counter)) Next End With
Error code: 381
Description: Invalid property array index
Source: _________ (<---database name)
Any help would be appreciated!
Thank you very much!




Reply With Quote