For...While Loop question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zags
    New Member
    • Aug 2007
    • 10

    #1

    For...While Loop question

    Access 2003, Windows XP

    I'm trying to loop through a series of records in a table. For each record I need to execute a series of queries and finally update a table with the results of the final query.

    Hoping someone could provide me some guidance on how to structure the script to get me started.

    appreciate the help
  • Stwange
    Recognized Expert New Member
    • Aug 2007
    • 126

    #2
    Originally posted by zags
    Access 2003, Windows XP

    I'm trying to loop through a series of records in a table. For each record I need to execute a series of queries and finally update a table with the results of the final query.

    Hoping someone could provide me some guidance on how to structure the script to get me started.

    appreciate the help
    You need to get the SQL query to locate whatever records you want. You can do this by going into the query designer, getting the query running, and then go to SQL View, and copying the text. Once you have this:

    dim rs as DAO.recordSet
    Set rs = DBEngine(0)(0). openRecordSet(p asteSQLstring)
    do while not rs.EOF
    'run the queries here. If you have already saved them you can run them with Docmd.openQuery ("queryName" )
    loop
    'UPDATE QUERY HERE (could be docmd.runSQL("U PDATE table SET field1 = 'whatever', field2 = 'whatever' WHERE field3 = 'whatever';)

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I don't understand why you have to do it record by record.

      Comment

      Working...