I am trying to run through a tutorial on recordsets, so I am following the tutorial here:
I have made the table as described, and tried to run this code:
Option Compare Database
Dim dbMyDB As Database
Dim rsMyRS As Recordset
Private Sub Form_Load()
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenReco rdset("MyTable" , dbOpenDynaset)
If Not rsMyRS.EOF Then rsMyRS.MoveFirs t
Do While Not rsMyRS.EOF
lstRecords.AddI tem rsMyRS!Name
lstRecords.Item Data(lstRecords .NewIndex) = rsMyRS!ID
rsMyRS.MoveNext
Loop
End Sub
However, I am getting an error with the .newindex command. I assume what this line of code is trying to do is assign the ID number of the Name field to the corresponding listbox entry. Is there another way to do it?
Thank you!
I have made the table as described, and tried to run this code:
Option Compare Database
Dim dbMyDB As Database
Dim rsMyRS As Recordset
Private Sub Form_Load()
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenReco rdset("MyTable" , dbOpenDynaset)
If Not rsMyRS.EOF Then rsMyRS.MoveFirs t
Do While Not rsMyRS.EOF
lstRecords.AddI tem rsMyRS!Name
lstRecords.Item Data(lstRecords .NewIndex) = rsMyRS!ID
rsMyRS.MoveNext
Loop
End Sub
However, I am getting an error with the .newindex command. I assume what this line of code is trying to do is assign the ID number of the Name field to the corresponding listbox entry. Is there another way to do it?
Thank you!
Comment