Loop through a table using Access '97 module

dougmcc1

Registered User.
Local time
Today, 06:32
Joined
Jul 29, 2004
Messages
27
I have a table with 1 field which contains strings. In an Access '97 module, how do I loop through this table and assign each string to a variable?

For example, lets say I have the following table:

Field of Strings
--------------
This is string1
This is string2

I need to get the string in the first row, assign it to a variable to be used in the code, then loop to the second row, assign the string in row 2 to be used in the code, and so on.

Thanks.
 
doug,

Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim SomeVariable As String

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("YourTable")
While not rst.EOF and not rst.BOF
   SomeVariable = rst!SomeField
   ' Do some stuff ...
   rst.MoveNext
   Wend

Wayne
 

Users who are viewing this thread

Back
Top Bottom