# Re: Hard to understand WHY

Posted by AndyLin on February 04, 1999 at 14:01:23:

In Reply to: Hard to understand WHY posted by Ta on February 04, 1999 at 13:15:03:

:
: Following are my codes:

: Dim qb as database
: dim cs as recordset

: Set qb = OpenDatabase("a:\access\businessdata.mdb")
: Set cs = qb.OpenRecordset("SalesRecord")

: cs.MoveLast
: cs.MoveFirst

: If I put these codes in DBcombo, it will show : For i = 1 To cs.RecordCount - 1
: List1.AddItem cs(i)
: cs.MoveNext
: Next i
error message "Item not found in this collection" . Problem is at List1.AddItem "cs(i)"

: If I put these codes in commandbox or form, it will show error message
: " user defined type not defined" Problem is at Dim "qb as database"

: Please help me solve problem. Thanks

For i = 1 To cs.RecordCount - 1
List1.AddItem cs(i) 'this is not cs(i),I shall is cs(fieldname)
cs.MoveNext
Next i

Follow Ups:

- Re: Hard to understand WHY Ta 05:24:02 2/05/99 (0)