Click to See Complete Forum and Search --> : Using VB 5.0 to index in an Access table


met12
June 9th, 2004, 09:55 PM
Hi,

I'm trying to index down through the table datainput and pull the Description out of each record. Count1 is the total number of records in the table, but I keep pulling the Description from the same record each time. It is not indexing. Any ideas would be much appreciated.

Thanks,
met12


For K = 1 To Count1
Set dbs = OpenDatabase("c:\vb\invenVB.mdb")
'Set rst = dbs.OpenRecordset("datainput")
Set rst = dbs.OpenRecordset("SELECT Description from datainput;")
check = rst.Fields(0).Value
MsgBox check
rst.Recordset.MoveNext
Next K

hspc
June 10th, 2004, 03:35 AM
Hi
inside the loop you open the database and the recordset again and again.So you start fetching records from the beginning

Set dbs = OpenDatabase("c:\vb\invenVB.mdb")
Set rst = dbs.OpenRecordset("SELECT Description from datainput;")
Do While not rst.EOF
check = rst.Fields(0).Value
MsgBox check
rst.Recordset.MoveNext
Loop
rst.Close
dbs.Close

met12
June 10th, 2004, 04:36 PM
Thanks,

Got it fixed