In other words, you're not simply returning a bunch of rows as the detail of
the form? You're actually populating 26 sets of controls with values? Sounds
unusual, but if that's the case you can simulate control arrays by using
naming conventions for your controls.
For instance, if you name your controls ItemNo1, ItemNo2, ItemNo3 and so on
upto ItemNo26, NoOfCartons1, NoOfCartons2, and so on to NoOfCartons26 and
so on, you could use code like:
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
(Note that if you've only got 26 controls, the sample code you posted would
have failed, since it loops until i is 26, and then looks for control i+1)
If, on the other hand, you actually have a "normal" form, with one set of
controls that is replicated for each row in the form's recordsource, it's
not possible to refer to individual controls like that. You'd have to work
with the form's recordset.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> So what's the solution for it?
> Do I have to write it for all 26 fields? It will be too long if I
> write it for all 26 fields.
> Thanks For ur reply.
billypit786@gmail.com - 05 Mar 2008 15:19 GMT