Results 1 to 4 of 4
  1. #1
    ahmed-aljawad is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    6

    this example of what i want

    plz i have a HR info table with a discount recored for the employee assume that an employee had more than one discount in a month how i can find the sum for that discount in one text box if its a form or a field if its queries help plz

    name date of discount discount
    smith 22jul2010 300
    smith 25aug2010 100
    smith 10 apr2010 200
    john 05mar2010 200
    john 10may2010 400


    i want the sum of smith for the three months and the sum for john for the tow months to be in a calculated queires or form


  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I think you have another similar thread this is what have I done:

    table HrInfo
    EmployeeID
    EmployeeName
    Date
    Discount


    I have a Form Form1 that gives you various options to find sum putting criteria. Follow the instruction on the form. DSum Code used:

    Private Sub Text15_AfterUpdate()
    Dim curSum As Currency
    curSum = IIf(IsNull(DSum("[Discount]", "HrInfo", "[EmployeeName]='" & Me.Text15 & "'And [Date] Between" & "#" & Me.Text11 & "# And #" & Me.Text13 & "#")), 0, DSum("[Discount]", "HrInfo", "[EmployeeName]='" & Me.Text15 & "'And [Date] Between" & "#" & Me.Text11 & "# And #" & Me.Text13 & "#"))
    Me.Text17 = curSum

    End Sub

    Private Sub Text3_AfterUpdate()
    Dim curSum As Currency
    curSum = IIf(IsNull(DSum("[Discount]", "HrInfo", "[EmployeeID]=" & Me.Text3)), 0, DSum("[Discount]", "HrInfo", "[EmployeeID]=" & Me.Text3))
    Me.Text0 = curSum
    End Sub

    Private Sub Text6_AfterUpdate()
    Dim curSum As Currency
    curSum = IIf(IsNull(DSum("[Discount]", "HrInfo", "[EmployeeName]='" & Me.Text6 & "'")), 0, DSum("[Discount]", "HrInfo", "[EmployeeName]='" & Me.Text6 & "'"))
    Me.Text8 = curSum

    End Sub

    Refer to the mdb file attached.

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    The codes are attached to the afterupdate event of the controls so please press enter after entering required criteria.

    Mark the thread solved if this solves your problem

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    is your problem solved if yes please mark this thread solved. And the other one too

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums