By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

for loop problem

100+
P: 101
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.
Expand|Select|Wrap|Line Numbers
  1. for(int i=1,j=17;i<=26,j<=32;i++,j++)
  2. {
  3. 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
  4. Me.NoOfPallet[i] = Me.NoOfPallet[i+1] + 1
  5. Me.TotalPieces[i] = (([NoOfPallet[i+1]] * ([NoOfCartons[i+1]] * [NoOfPiecesPerCartons[i])))
  6. Me.PalletNo[i] = Me.PalletNo[i] + ";" + Me.PalletNo[i+1]
  7. Me.PalletNo[i+1] = Null
  8. Me.ItemNo[i+1] = Null
  9. Me.Description[i+1] = Null
  10. Me.NoOfPallet[i+1] = Null
  11. Me.NoOfCartons[i+1] = Null
  12. Me.NoOfPiecesPerCartons[i+1] = Null
  13. Me.NoOfPartialCartons[i+1] = Null
  14. Me.NoOfPiecesPerPartialCartons[i+1] = Null
  15. Me.NoOfPartialCartons[j+1] = Null
  16. Me.NoOfPiecesPerPartialCartons[j+1] = Null
  17. Me.TotalPieces[i+1] = Null
  18. Me.BatchOrLotNo[i+1] = Null
  19. Me.PONo[i+1] = Null
  20. Me.LONo[i+1] = Null
  21. Me.PalletNo[i+1].SetFocus
  22. }
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.
Mar 4 '08 #1
Share this Question
Share on Google+
5 Replies


Denburt
Expert 100+
P: 1,356
Try utilizing something like the following:

Expand|Select|Wrap|Line Numbers
  1. for i=17 to 26 
  2. If Me("ItemNo" & i+1) = Me("ItemNo" & i) then
  3. 'Do Something here
  4. Else
  5. 'something else
  6. end if
  7. next
Mar 5 '08 #2

100+
P: 101
Thanks For ur Reply.I got the same solution.
Mar 5 '08 #3

Denburt
Expert 100+
P: 1,356
You are quite welcome, glad I could be of assistance.
Mar 5 '08 #4

NeoPa
Expert Mod 15k+
P: 31,186
You can also specify a STEP value if required.
Mar 6 '08 #5

100+
P: 101
You can also specify a STEP value if required.
Ya I know that thing.Thanks
Mar 6 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.