Looping through a table for a form

D

David

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.
 
J

James Goodman

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top