Looping through records (1 Viewer)

ayeshamiah

Registered User.
Local time
Today, 09:25
Joined
May 24, 2000
Messages
20
Hi all access gurus,

I know nothing about access and would appreciate any advice. I have created a table and want to loop through the recordset and access one particular field for every record. How can I do this in vba

TIA, Ayesha
 

Mitch

Registered User.
Local time
Today, 09:25
Joined
May 23, 2000
Messages
31
Ok here goes

' Declare you variables
Dim dbs as database
Dim rst as recordset
Dim Counter as integer

' set up a updateable recordset of your table
Set dbs = CurrentDB
Set rst = dbs.openrecordset("SELECT * FROM [YourTableName]", dbopendynaset)

' find number of records in your recordset
counter = rst.recordcount

' loop until run out of records
while counter > 0

with rst
' sets your field to date for example
![fldYourField] = Date
end with

' moves to next record
rst.movenext

' one less record to go
counter = counter - 1

' start loop again
wend

This will set all that field to the current date in all the record in that table, hope this was what you where looking for.

Mitch.
 

Users who are viewing this thread

Top Bottom