S
Simon Harris
Hi All,
I've just spent 3 hours working on getting a simple recordset loop to go
through all the records that the SQL returned.
Heres my code, commented with how I eventually fixed it:
Dim conn As DAO.Database
Set RSCheckCurrentReadings = conn.OpenRecordset(strSQL)
RSCheckCurrentReadings.MoveFirst <<< Without these two lines, the
recordset loop only returned 1 record
RSCheckCurrentReadings.MoveLast <<<
Do While Not RSCheckCurrentReadings.EOF
MsgBox (CInt(RSCheckCurrentReadings("idInvoice")))
Loop
Hopefully that will be helpful to someone in the future, took me a lot of
Googling to work it out.
Thanks to Graham Mandeno and John Vinson for giving me some very useful
pointers in solving this.
http://groups.google.co.uk/group/mi...b12ed5fc?lnk=st&rnum=5&hl=en#59b0de72b12ed5fc
But...I still dont understand why I need to movelast AND movefirst. (Move
first before a loop I can understand).
Cheers all!
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
I've just spent 3 hours working on getting a simple recordset loop to go
through all the records that the SQL returned.
Heres my code, commented with how I eventually fixed it:
Dim conn As DAO.Database
Set RSCheckCurrentReadings = conn.OpenRecordset(strSQL)
RSCheckCurrentReadings.MoveFirst <<< Without these two lines, the
recordset loop only returned 1 record
RSCheckCurrentReadings.MoveLast <<<
Do While Not RSCheckCurrentReadings.EOF
MsgBox (CInt(RSCheckCurrentReadings("idInvoice")))
Loop
Hopefully that will be helpful to someone in the future, took me a lot of
Googling to work it out.
Thanks to Graham Mandeno and John Vinson for giving me some very useful
pointers in solving this.
http://groups.google.co.uk/group/mi...b12ed5fc?lnk=st&rnum=5&hl=en#59b0de72b12ed5fc
But...I still dont understand why I need to movelast AND movefirst. (Move
first before a loop I can understand).
Cheers all!
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!