Help with code

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Could anyone tell me how to fix my code?

I have 6 text boxes named amount1, amount2, amount3, ...,
amount6 and 6 more text boxes named payment1, payment2,
payment3, ... payment6. What I want to do is check if the
value in each of the amount text boxes is equal to 0 and
if they are then I want to add the total amount of the
corresponding payment text box to the text box named
[amount due]

Here is what I have so far:

Dim paymentNumSelected As String
For counter = 1 To 6
paymentNumSelected = "payment" & counter
If Me.[paymentNumSelected] = 0 Then
Me.[Amount Due] = Me.[Amount Due] + ["Amount"
& counter] + ["Late Fee" & counter] + counter
End If
Next

It keeps telling me that the field referenced cant be
found (Me.[paymentNumSelected]) but I checked and the
paymentNumSelected is equal to payment1, then payment2,
then payment3 and so on through the loop.
 
Dan,

Dim paymentNumSelected As String
Dim counter As Integer

For counter = 1 To 6
paymentNumSelected = "payment" & counter
If Me(paymentNumSelected) = 0 Then
Me("Amount Due") = Me("Amount Due") + _
Me(paymentNumSelected) + _
Me("Late Fee" & counter) + _
counter
End If
Next

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top