اخي انا لا اعلم بصحه النتايج
ولكن الوحده النمطيه بتكون هذا
واذا في خطاء اخبرني
Option Compare Database
Function Assist()
On Error Resume Next
form1.MySubNum = Year(EndDate) - Year(FirstDate)
'---------------------------------------------------------------------------------
Dim x As Integer
form1.Form.SetFocus
form1.Frm1.SetFocus
form1.Frm1.Form.ShopDate.SetFocus
DoCmd.GoToRecord , , acFirst
For x = 1 To Form_Form1.MySubNum
form1_Form_Frm1.ID = x
DoCmd.GoToRecord , , acNext
Next x
'-------------------------------------------------------------------------------------------
On Error Resume Next
Dim i As Integer
form1.Form.SetFocus
form1.Frm1.SetFocus
form1.Frm1.Form.ShopDate.SetFocus
DoCmd.GoToRecord , , acFirst
For i = 1 To Form1_Frm1.Form.Recordset.RecordCount
If Month(form_Form_Frm1.ShopDate) <> 12 Then
form1_Form_Frm1.EndtharSum = form1.Cost * form1.IndtharRute * ((12 - Month(form_Form_Frm1.ShopDate)) / 12)
Form1_Form1_Form_Frm1.EndtharYear = form1.Cost * form1.IndtharRute * ((12 - Month(form_Form_Frm1.ShopDate)) / 12)
Else
form1_Form_Frm1.EndtharSum = form1.Cost * form1.IndtharRute
form1_Form_Frm1.EndtharYear = form1.Cost * form1.IndtharRute
End If
DoCmd.GoToRecord , , acNext
Next i
form1.Refresh
'-------------------------------------------------------------------------------------------
If form1.FirstDate And form1.EndDate >= "" Then
Dim FariqYear As Integer
FariqYear = DateDiff("yyyy", form1.FirstDate, form1.EndDate)
form1.Form.SetFocus
Forms!form1.Frm1.SetFocus
Forms!form1.Frm1.Form.ShopDate.SetFocus
DoCmd.GoToRecord , , acFirst
For i = 1 To form1.Frm1.Form.Recordset.RecordCount
If Month(form1.FirstDate) <> 12 Then
If i = 1 Then
form1_Form_Frm1.ShopDate = form1.FirstDate
ElseIf i = 1 Then
form1_Form_Frm1.ShopDate = "31/12/" & Year(form1.FirstDate)
Else
form1_Form_Frm1.ShopDate = "31/12/" & Year(form1.FirstDate) + (i - 1)
End If
Else
If i = 1 Then
form1_Form_Frm1.ShopDate = "31/12/" & Year(form1.FirstDate)
Else
form1_Form_Frm1.ShopDate = "31/12/" & Year(form1.FirstDate) + (i - 1)
End If
End If
DoCmd.GoToRecord , , acNext
Next i
Else
MsgBox "رجاءا ادخل تاريخ الشراء وتاريخ اخر الفترة"
End If
form1.Refresh
End Function