Looping through a table for a form

  • Thread starter Thread starter David
  • Start date Start date
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.
 
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...
 
Back
Top