Looping through records in a subform

M

Melissa

HELP! I've been struggling for awhile on this and would appreciate any help.
I am trying to create a command button that once clicked will notify the
user via a message box that the order they placed did not meet certian
criteria.

Here's the code I came up with. What is wrong with it? It keeps looping,
but when I break it, VBA highlights the Case 1 to 4 line.

Do Until rstOrders.EOF
Select Case rstOrders.MOQ
Case 1 To 4
intDifference = rstOrders.Quantity Mod rstOrders.containersize
If Not intDifference = 0 Then
strMessage = strMessage & "Item #" & """ & rstOrders.ItemNumber & """ & _
" - ordered quantity of " & """ & rstorders.quantity & """ & " does not meet
" & _
""" & rstOrders.Containertype & """ & " of " & """ & rstOrders.containersize
& """ & _
Chr(13)
Else
End If
Case 5
If rstOrders.Quantity < rstOrders.containersize Then
strMessage = strMessage & "Item #" & """ & rstOrders.ItemNumber & """ & _
" - ordered quantity of " & """ & rstorders.quantity & """ & " does not meet
" & _
""" & rstOrders.Containertype & """ & " of " & """ & rstOrders.containersize
& """ & _
Chr(13)
End If
End Select
Loop
Thanks.
 
E

ErezM via AccessMonster.com

hi
the loop is supposed to step through the whole recordset (that's why it
starts by saying "do this until you get to the EndOfFile of rstOrders..."
but your code never moves beyond the first record, let alone arrive at the
end

so just add
rstOrders.MoveNext
before the "Loop" command

good luck
 
Top