Private Sub Command54_Click()
DoCmd.Close acForm, "YEORDERS", acSaveYes
DoCmd.OpenForm "YEPARTS", acNormal, "", "", , acNormal
DoCmd.OpenForm "YEORDERS", acFormDS, "", acEdit,
acNormal
DoCmd.OpenForm "YEORDERS", acFormDS, "", "[NUM]=
[Forms]![YEPARTS]![NUM]", acEdit, acNormal
DoCmd.FindRecord Forms!YEPARTS!NUM, acEntire, True, ,
True, , True
' find first
num on orders that matches parts
Forms!YEPARTS!BUYU = Forms!YEORDERS!BUYUNIT
Forms!YEPARTS!ENDINV = Forms!YEORDERS!ENDINV
'PROCESS 1ST BUY
Forms!YEPARTS![TOTALRECD 1] = Forms!YEORDERS!TOTALRECD
Forms!YEPARTS![PRICE 1] = Forms!YEORDERS!PRICE
If (Forms!YEPARTS!ENDINV <= Forms!YEPARTS![TOTALRECD
1]) Then
Forms!YEPARTS![QTYTOPRICE 1] = Forms!YEPARTS!
ENDINV
End If
If (Forms!YEPARTS!ENDINV > Forms!YEPARTS![TOTALRECD
1]) Then
Forms!YEPARTS![QTYTOPRICE 1] = Forms!YEPARTS!
[TOTALRECD 1]
End If
Forms!YEPARTS![TOTAL 1] = Forms!YEPARTS![QTYTOPRICE 1]
* Forms!YEPARTS![PRICE 1]
Forms!YEPARTS!TOTALPRICE = Forms!YEPARTS![TOTAL 1]
'PROCESS 2ND BUY
DoCmd.GoToRecord , "", acNext
Forms!YEPARTS![TOTALRECD 2] = Forms!YEORDERS!TOTALRECD
Forms!YEPARTS![EXCESS 2] = Forms!YEPARTS!ENDINV -
Forms!YEPARTS![QTYTOPRICE 1]
Forms!YEPARTS![PRICE 2] = Forms!YEORDERS!PRICE
If (Forms!YEPARTS![EXCESS 2] <= Forms!YEPARTS!
[TOTALRECD 2]) Then
Forms!YEPARTS![QTYTOPRICE 2] = Forms!YEPARTS!
[EXCESS 2]
End If
If (Forms!YEPARTS![EXCESS 2] > Forms!YEPARTS!
[TOTALRECD 2]) Then
Forms!YEPARTS![QTYTOPRICE 2] = Forms!YEPARTS!
[TOTALRECD 2]
End If
Forms!YEPARTS![TOTAL 2] = Forms!YEPARTS![QTYTOPRICE 2]
* Forms!YEPARTS![PRICE 2]
Forms!YEPARTS!TOTALPRICE = Forms!YEPARTS![TOTAL 1] +
Forms!YEPARTS![TOTAL 2]
'PROCESS 3RD BUY
DoCmd.GoToRecord , "", acNext ' go to 3rd
record on orders form
If (Forms!YEORDERS!NUM > Forms!YEPARTS!NUM) Then
DoCmd.GoToRecord , "", acNext
End If
Forms!YEPARTS![TOTALRECD 3] = Forms!YEORDERS!TOTALRECD
Forms!YEPARTS![EXCESS 3] = Forms!YEPARTS![EXCESS 2] -
Forms!YEPARTS![QTYTOPRICE 2]
Forms!YEPARTS![PRICE 3] = Forms!YEORDERS!PRICE
If (Forms!YEPARTS![EXCESS 3] <= Forms!YEPARTS!
[TOTALRECD 3]) Then
Forms!YEPARTS![QTYTOPRICE 3] = Forms!YEPARTS!
[EXCESS 3]
End If
If (Forms!YEPARTS![EXCESS 3] > Forms!YEPARTS!
[TOTALRECD 3]) Then
Forms!YEPARTS![QTYTOPRICE 3] = Forms!
YEPARTS![TOTALRECD 3]
End If
Forms!YEPARTS![TOTAL 3] = Forms!YEPARTS![QTYTOPRICE 3]
* Forms!YEPARTS![PRICE 3]
Forms!YEPARTS!TOTALPRICE = Forms!YEPARTS![TOTAL 1] +
Forms!YEPARTS![TOTAL 2] + Forms!YEPARTS![TOTAL 3]
'PROCESS 4TH BUY
DoCmd.GoToRecord , "", acNext ' go to 4th
record on orders form
If (Forms!YEORDERS!NUM > Forms!YEPARTS!NUM) Then
DoCmd.GoToRecord , "", acNext
End If
Forms!YEPARTS![TOTALRECD 4] = Forms!YEORDERS!TOTALRECD
Forms!YEPARTS![EXCESS 4] = Forms!YEPARTS![EXCESS 3] -
Forms!YEPARTS![QTYTOPRICE 3]
Forms!YEPARTS![PRICE 4] = Forms!YEORDERS!PRICE
If (Forms!YEPARTS![EXCESS 4] <= Forms!YEPARTS!
[TOTALRECD 4]) Then
Forms!YEPARTS![QTYTOPRICE 4] = Forms!
YEPARTS![EXCESS 4]
End If
If (Forms!YEPARTS![EXCESS 4] > Forms!YEPARTS!
[TOTALRECD 4]) Then
Forms!YEPARTS![QTYTOPRICE 4] = Forms!
YEPARTS![TOTALRECD 4]
End If
Forms!YEPARTS![TOTAL 4] = Forms!YEPARTS![QTYTOPRICE 4]
* Forms!YEPARTS![PRICE 4]
'SUMMARIZE ALL 4 BUYS
Forms!YEPARTS!TOTALQTY = Forms!YEPARTS![QTYTOPRICE 1]
+ Forms!YEPARTS![QTYTOPRICE 2] + Forms!YEPARTS![QTYTOPRICE
3] + Forms!YEPARTS![QTYTOPRICE 4]
Forms!YEPARTS!TOTALPRICE = Forms!YEPARTS![TOTAL 1] +
Forms!YEPARTS![TOTAL 2] + Forms!YEPARTS![TOTAL 3] + Forms!
YEPARTS![TOTAL 4]
End Sub
-----Original Message-----
Please post the code. Are you processing a *file* using VBA I/O
statements, or are you stepping through a *recordset* using DAO or
ADO objects? It makes a big difference.