-
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
-
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.
-
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
-
is your problem solved if yes please mark this thread solved. And the other one too
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules