اتفضل اخي ابو زاهر
Dim i As Integer
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.MoveLast: rst.MoveFirst
RC = rst.RecordCount
rst.MoveFirst
Forms![frmSales].SetFocus
Forms![frmSales]![SubSales].SetFocus
For i = 1 To RC
Me.Refresh
If rst!Xsave = True Then
DoCmd.GoToRecord , , acNewRec
Forms![frmSales]![SubSales]![رقم_الصنف] = rst!Rajmsanf
Forms![frmSales]![SubSales]![ID_Sanf] = rst!ID_Sanf
Forms![frmSales]![SubSales]![Alkmiah] = rst!Alkmiah
Forms![frmSales]![SubSales]![Price] = DLookup("[Price_Sales]", "Alsnaf", "[Rajmsanf]= Forms![frmSales]![SubSales]![رقم_الصنف] ")
Forms![frmSales]![SubSales]![mjmo] = rst!mjmo
' Forms![frmSales]![SubSales]![safi] = rst!safi
Forms![frmSales]![SubSales]![Adfah] = rst!Adfah
Forms![frmSales]![SubSales]![Nwaha] = Me.n3
End If
rst.MoveNext
Next i
rst.Close: Set rst = Nothing
' Dim rst As DAO.Recordset
Set rst = Forms!frmSales!SubSales.Form.RecordsetClone
rst.MoveLast: rst.MoveFirst
RC = rst.RecordCount
T = 0 'Total
D = 0 'Discount
For i = 1 To RC
rst.Edit
rst!mjmo = rst!Alkmiah * rst!Price
rst!safi = rst!Alkmiah * rst!Price * (1 - Forms!frmSales!Percentage_Discount)
T = T + (rst!Alkmiah * rst!Price)
D = D + (rst!Alkmiah * rst!Price * Forms!frmSales!Percentage_Discount)
rst.Update
rst.MoveNext
Next i
rst.Close: Set rst = Nothing
DoCmd.RunCommand acCmdSaveRecord
Forms!frmSales!n1 = T
Forms!frmSales!Alhasm = D
Forms!frmSales!n2 = T - D
Rajmsanf.SetFocus
Call Form_frmSales.Percentage_Discount_AfterUpdate
DoCmd.Close acForm, "ARD"