اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

التعديل على كود توزيع


كريمو2

الردود الموصى بها

السلام عليكم اساتذتي الكرام

هذا الكود من انتاج الأستاذ جعفر حفظه  الله ورعاه

 بس لما غيرت به شيء بسيط اصبح لايقوم بالتوزيع كما هو مطلوب

Private Sub UpdateEndData()
    Dim Dcode As Integer

    'since we are using the calendar, we will get the day, month, and year,
    'although we only need the month and the year, and that is what this fields Format shows, mmmm\-yyyy
    'but for easyness for the search later, we will assign the day always as 1
    
    If Len(Me.AwardMonth & "") <> 0 Then
        Me.AwardMonth = DateSerial(Year(Me.AwardMonth), Month(Me.AwardMonth), 1)
    End If
    
    Me.DiscountStartDate = DateSerial(Year(Me.DiscountStartDate), Month(Me.DiscountStartDate), 1)
    
    Dcode = Switch([Cridi_ID] > 0, 10)
    DiscountEndDate = DateAdd("m", Dcode, [DiscountStartDate] - 1)
    Me.DiscountEndDate = DateSerial(Year(Me.DiscountEndDate), Month(Me.DiscountEndDate) + 1, 0)
    DiscountPerMonth = (([Cridi_Value] - [Mont_Spés]) * [Qte]) / Dcode


    'add the loan Records to tbl_Loans
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("Select * From tbl_Loans")
    'rst.MoveLast: rst.MoveFirst
    
    For I = 0 To Me.CmdCridi.Column(0) - 1
                    
        rst.AddNew

        rst!EmployeeID = Me.EmployeeID
        rst!Loan_ID = Me.ID
        rst!Loan_AwardMonth = Me.AwardMonth
        rst!Payment_Month = DateAdd("m", I, Me.DiscountStartDate)   'add the months, or use the next line
        'rst!Payment_Month = DateSerial(Year(Me.DiscountStartDate), Month(Me.DiscountStartDate) + I, 1)
        rst!Loan_Cridi = Me.txtDiscountPerMonth
        'rst!Payment_Made =     'to be used each time a pyment is made
        rst!Loan_Type = "Cridi"
        rst!Remarks = Me.CmdCridi.Column(1)
        
        rst.Update
        
    Next I
    
    rst.Close: Set rst = Nothing
    
txtDiscountPerMonth.Requery
txtDiscountEndDate.Requery

'Auto_ID, Auto_Date, EmployeeID, Loan_ID, Loan_AwardMonth, Payment_Month, Loan_Cridi, Payment_Amount, Payment_Made, Remarks
'EmployeeID
'Loan_ID
'Loan_AwardMonth
'Payment_Month'
'Loan_Cridi
'Payment_Amount
'Payment_Made
'Remarks
End Sub

 Beriod ولما غيرت تقسيم 10 على مربع نص به عدد وهو 

Private Sub UpdateEndData()
    Dim Dcode As Integer

    'since we are using the calendar, we will get the day, month, and year,
    'although we only need the month and the year, and that is what this fields Format shows, mmmm\-yyyy
    'but for easyness for the search later, we will assign the day always as 1
    
    If Len(Me.AwardMonth & "") <> 0 Then
        Me.AwardMonth = DateSerial(Year(Me.AwardMonth), Month(Me.AwardMonth), 1)
    End If
    
    Me.DiscountStartDate = DateSerial(Year(Me.DiscountStartDate), Month(Me.DiscountStartDate), 1)
    
    Dcode = Switch([Cridi_ID] > 0, [Beriod])
    DiscountEndDate = DateAdd("m", Dcode, [DiscountStartDate] - 1)
    Me.DiscountEndDate = DateSerial(Year(Me.DiscountEndDate), Month(Me.DiscountEndDate) + 1, 0)
    DiscountPerMonth = (([Cridi_Value] - [Mont_Spés]) * [Qte]) / Dcode


    'add the loan Records to tbl_Loans
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("Select * From tbl_Loans")
    'rst.MoveLast: rst.MoveFirst
    
    For I = 0 To Me.CmdCridi.Column(0) - 1
                    
        rst.AddNew

        rst!EmployeeID = Me.EmployeeID
        rst!Loan_ID = Me.ID
        rst!Loan_AwardMonth = Me.AwardMonth
        rst!Payment_Month = DateAdd("m", I, Me.DiscountStartDate)   'add the months, or use the next line
        'rst!Payment_Month = DateSerial(Year(Me.DiscountStartDate), Month(Me.DiscountStartDate) + I, 1)
        rst!Loan_Cridi = Me.txtDiscountPerMonth
        'rst!Payment_Made =     'to be used each time a pyment is made
        rst!Loan_Type = "Cridi"
        rst!Remarks = Me.CmdCridi.Column(1)
        
        rst.Update
        
    Next I
    
    rst.Close: Set rst = Nothing
    
txtDiscountPerMonth.Requery
txtDiscountEndDate.Requery

'Auto_ID, Auto_Date, EmployeeID, Loan_ID, Loan_AwardMonth, Payment_Month, Loan_Cridi, Payment_Amount, Payment_Made, Remarks
'EmployeeID
'Loan_ID
'Loan_AwardMonth
'Payment_Month'
'Loan_Cridi
'Payment_Amount
'Payment_Made
'Remarks
End Sub

 Beriod اصبح يقسم القسط على شهر واحد فقط بدلا من الشهر الذي يكتب في مربع النص 

 Dcode = Switch([Cridi_ID] > 0, 10)
 Dcode = Switch([Cridi_ID] > 0, [Beriod])

أرجو المساعدة

تم تعديل بواسطه كريمو2
رابط هذا التعليق
شارك

اذا تريد ان يقسم على 6 اي الرقم المكتوب في حقل المدة فقط عليك ان تغير هذا السطر من الكود 

 For I = 0 To Me.CmdCridi.Column(0) - 1

بهذا السطر

    For I = 0 To Me.Beriod - 1

واليك المرفق بعد تعديل

 

v2برنامج التقسيط.rar

  • Like 1
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • اضف...

Important Information