for loop problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billa856
    New Member
    • Nov 2007
    • 101

    for loop problem

    Hi,
    My project is in MS Access 2002.
    In that I have one form. In that I want to put For or Do While loop.
    I want thing like this in Access.
    This is in C++ format.
    Code:
    for(int i=1,j=17;i<=26,j<=32;i++,j++)
    {
    If ((Me.ItemNo[i+1] = Me.ItemNo[i]) And (Me.NoOfCartons[i+1] = Me.NoOfCartons[i]) And (Me.NoOfPiecesPerPartialCartons[i+1] = 0) And (Me.BatchOrLotNo[i+1] = Me.BatchOrLotNo[i]) And (Me.LONo[i+1] = Me.LONo[i])) Then
    Me.NoOfPallet[i] = Me.NoOfPallet[i+1] + 1
    Me.TotalPieces[i] = (([NoOfPallet[i+1]] * ([NoOfCartons[i+1]] * [NoOfPiecesPerCartons[i])))
    Me.PalletNo[i] = Me.PalletNo[i] + ";" + Me.PalletNo[i+1]
    Me.PalletNo[i+1] = Null
    Me.ItemNo[i+1] = Null
    Me.Description[i+1] = Null
    Me.NoOfPallet[i+1] = Null
    Me.NoOfCartons[i+1] = Null
    Me.NoOfPiecesPerCartons[i+1] = Null
    Me.NoOfPartialCartons[i+1] = Null
    Me.NoOfPiecesPerPartialCartons[i+1] = Null
    Me.NoOfPartialCartons[j+1] = Null
    Me.NoOfPiecesPerPartialCartons[j+1] = Null
    Me.TotalPieces[i+1] = Null
    Me.BatchOrLotNo[i+1] = Null
    Me.PONo[i+1] = Null
    Me.LONo[i+1] = Null
    Me.PalletNo[i+1].SetFocus
    }
    but it shows error.
    Loop is ok but I am using [i] and [i+1] i think that's not right.I think it array something but I don't know how to do it?
    any solution of this thing?
    Thanks.
  • Denburt
    Recognized Expert Top Contributor
    • Mar 2007
    • 1356

    #2
    Try utilizing something like the following:

    [code=vb]for i=17 to 26
    If Me("ItemNo" & i+1) = Me("ItemNo" & i) then
    'Do Something here
    Else
    'something else
    end if
    next[/code]

    Comment

    • billa856
      New Member
      • Nov 2007
      • 101

      #3
      Thanks For ur Reply.I got the same solution.

      Comment

      • Denburt
        Recognized Expert Top Contributor
        • Mar 2007
        • 1356

        #4
        You are quite welcome, glad I could be of assistance.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32636

          #5
          You can also specify a STEP value if required.

          Comment

          • billa856
            New Member
            • Nov 2007
            • 101

            #6
            Originally posted by NeoPa
            You can also specify a STEP value if required.
            Ya I know that thing.Thanks

            Comment

            Working...