Results 1 to 3 of 3
  1. #1
    system243trd is offline Novice
    Windows 2K Access 2003
    Join Date
    Nov 2011
    Posts
    27

    Help with For Next code

    Hi ,


    I am reading an access book and have come accross some code for a FOR NEXT statement.

    Please could someone explain the process of what is being done below?

    For i = 1 To 10000
    For j = 1 To 10000
    sExplicit = i / 0.33333
    Next j
    Next i

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    It doesn't make much sense like that, but generally the first time through i will be 1, so the variable named sExplicit will be set to the mathematical result of 1 divided by .33333. The second pass through i will be equal to 2, so the variable will be set to 2/.33333, and so on.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    My (additional) $.02

    It is a form of looping. It is easier to see if formatted:
    Code:
    For i = 1 To 10000     'outer loop
        For j = 1 To 10000   'inner loop
          sExplicit = i / 0.33333
        Next j
    Next i
    There are two loops: i (the outer loop) & j (the inner loop). The inner loop, j, executes 10,000 times for each value of i, the outer loop. If you added code to add a record for each calculated value of "sExplicit", your table would end up with 100,000,000 new records (10,000 X 10,000).

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

Similar Threads

  1. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  2. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  3. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 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