Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2007
    Posts
    49

    Unanswered: 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.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes
    look in the help file for control structures
    if
    do while
    for loops

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    The For loop would look some like

    For i=1 to 26
    For j=17 to 32
    ....
    ...
    .....
    ...
    next j
    next i

    working with the feild

    long time a go rem something like (not at my computer)

    Me.ItemNo[i+1] would be me!("ItemNp"& i+1)
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  4. #4
    Join Date
    Dec 2007
    Posts
    49
    Thanks For Ur Reply.Let me see it will work or not in my case.

  5. #5
    Join Date
    Dec 2007
    Posts
    49
    Its working and its like this.

    For i = 1 To 25
    If ((Me.Controls("ItemNo" & (i+1)) = Me.Controls("ItemNo" & i) _
    And (Me.Controls("NoOfCartons" & (i+1)) = Me.Controls("NoOfCartons" & i)
    _
    And (Me.Controls("NoOfPiecesPerPartialCartons" & (i+1)) = 0) _
    And (Me.Controls("BatchOrLotNo" & (i+1)) = Me.Controls("BatchOrLotNo" &
    i) _
    And (Me.Controls("LONo" & (i+1)) = Me.Controls("LONo" & i)) Then


    Me.Controls("NoOfPallet" & i) = Me.Controls("NoOfPallet" & (i+1)) + 1
    Me.Controls("TotalPieces" & i) = ((Me.Controls("NoOfPallet" & (i+1)) * _
    (Me.Controls("NoOfCartons" & (i+1)) *
    Me.Controls("NoOfPiecesPerCartons" & i)))


    etc


    Next i

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •