Re: Looping through a table for a form

From: James Goodman (james_at_norton-associates.REMOVE.co.uk)
Date: 02/18/04


Date: Wed, 18 Feb 2004 09:11:53 +0000 (UTC)

Yes, you will be wanting to use either ado or dao.

Using ado:
Sub ADOTest()
Dim cnn as New ADODB.Connection
Dim rst as New ADODB.Recordset

Set cnn = CurrentProject.Connection 'N.B. You can connect to another
database if you wish

rst.Open ("tblName"), cnn, adOpenStatic, adLockPessimistic

Do
    'Do stuff with your table here...
Loop While Not rst.EOF

rst.close
cnn.close
Set rst = nothing
Set cnn = nothing

End Sub

However, first consider if you can do this through a query or not. If
possible use a query as it will give better performance...

"David" <anonymous@discussions.microsoft.com> wrote in message
news:1234601c3f5f5$bf357490$a401280a@phx.gbl...
> Hi guys,
>
> Does anyone know how to loop through a table in Access
> 2000 and read off values, manipulate the data and then
> show the results on the form?
>
> Any help on looping through the table would be extremely
> helpful to me. I can figure out the rest!
>
> Thanks.