[AccessD] A2K: Another Recordset Syntax Q

Darren DICK d.dick at uws.edu.au
Tue Sep 7 02:02:22 CDT 2004


Andy you da man!!!!!!!!!!!!
Outstanding
Just what I needed
I've put it in the dB already and it works beautifully
Many many thanks

SYWYE

Have a fantastic day

Darren



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Andy Lacey
Sent: Tuesday, 7 September 2004 4:46 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] A2K: Another Recordset Syntax Q


Hi Darren

The .MoveLast is the problem. It takes you to the last record. After that
there is no Next to move to. To go through all records this is better.

Set rst=.....
Do While Not rst.EOF
	la de da
	rst.MoveNext
Loop

When you open a recordset the record pointer is placed on the first record
so you don't need a MoveFirst.

Another thing. A recordset's .RecordCount is only available after going to
the end of the recordset (ie after a .MoveLast), so you can't do your For
cos .Recordcount would be 0 if you just opened the recordset.

And finally .MoveLast crashes if there are 0 records in the recordset, so if
you did want a recordcount you'd have to do something like this:

Set rst=...
If not rst.eof
	rst.MoveLast
	msgbox rst.recordcount
	rst.MoveFirst
	Do While Not rst.EOF
		la de da
		rst.MoveNext
	Loop
End If


Have fun.

-- Andy Lacey
http://www.minstersystems.co.uk 



> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK
> Sent: 07 September 2004 07:26
> To: 'Access Developers discussion and problem solving'
> Subject: [AccessD] A2K: Another Recordset Syntax Q
> 
> 
> Hello all
> Another recordset syntax question
> One day I'll get it < sigh >
> 
> The code below does what it is supposed to do except move to
> the next site name in the recordset WHAT I WANT... I expect 
> the Message box to spit up SiteName1 then I expect another message
> box: SiteName 2 then another 
> Until all the SiteNames in the Recordset are iterated and 
> displayed in sequential message boxes
> 
> Problem is I get 5 message boxes (There's 5 site sin the
> recordset) but always the 1st Sitename 
> never site 2 or 3 or 4 or 5
> 
> Something backwards in the syntax or not properly placed is suppose
> 
> Need help - Any takers?
> 
> Many thanks in advance
> 
> Darren
> 
>   For x = 1 To rs.RecordCount
>   	With rs
> 	      .MoveLast
>       	 MsgBox !SiteName
>             .MoveNext
>       End With
>   Next
> 
> Have a great day
> 
> Darren
> 
> 
> --
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com 
> http://databaseadvisors.com/mailman/listinfo/a> ccessd
> Website: 
> http://www.databaseadvisors.com
> 
> 

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list