# Thread: Find a PayDate when deduction reaches amount (2000)

1. ## Find a PayDate when deduction reaches amount (2000)

Here's the situation. Employees have payroll deductions. I need to find out the paydate when a certain deduction reaches over \$200. I'm not sure how to do this.

This is what I have so far.
I have a form with a txtReportDate and txtDeductionAmt and a command button. Here's what i have behind the command button.

Private Sub Command3_Click()

Dim dtNextPayDate As Date
dtNextPayDate = #1/3/2003# 'This is the first paydate of this year.

Dim intCount As Integer
intCount = 0

Dim intAmount As Integer 'not using this variable yet
intAmount = Me.txtDeductionAmt

'lists and counts the number of pay dates between the variable and the date on the form
Do Until dtNextPayDate >= Me.txtReportDate
dtNextPayDate = dtNextPayDate + 14
intCount = intCount + 1
Loop

MsgBox "Done. " & intCount & " pay periods."

End Sub

How do I add the calculation of the deduction amounts? Do I need to store the paydates in an array so I can do a For Each...Next loop adding the deduction amounts together for each paydate?

I'm not sure what sort of logic I need to do. Thanks.
Sarah

2. ## Re: Find a PayDate when deduction reaches amount (2000)

Hi Sarah...

There are a lot of questions that come to mind but I

3. ## Re: Find a PayDate when deduction reaches amount (2000)

Yes, I realize my code was not doing what I wanted, but I was guessing that the loop could be modified to do what I wanted. It just was a starting point.

You assumed right. The code you suggested worked out good for me.

Thanks for the help.
Sarah

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•