Results 1 to 3 of 3
  1. #1
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72

    How to loop through each record in table

    Hi all,



    I have a code to do things to a record but i want to perform that on every record in a table. Can someone help me with the vba to loop through every record in a table (tablename:Assets).

    thanks.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe some DAO

    Code:
    Dim oRS As DAO.Recordset
    
    Set oRS = CurrentDb.OpenRecordset("Assets", dbOpenDynaset)
    oRS.Movefirst
    
    while oRS.eof = false
    
    'Do Something
    
    oRS.MoveNext
    wend
    
    oRS.close
    set oRS = nothing

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Here's a link that will help you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 04-07-2014, 07:48 PM
  2. Replies: 2
    Last Post: 11-15-2013, 09:58 AM
  3. Replies: 3
    Last Post: 03-10-2013, 07:04 AM
  4. Loop function not moving to next record
    By jax1000rr in forum Programming
    Replies: 3
    Last Post: 02-26-2013, 12:21 PM
  5. Loop until last record in excel table
    By compooper in forum Programming
    Replies: 5
    Last Post: 06-30-2011, 02:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums