NOBODY WANTS TO HELP???

  • Thread starter Thread starter irentcars
  • Start date Start date
I

irentcars

Guest
I have 3 separate loops in my procedure that calculate an amount....how can I make the amount I am calculating return to the corresponding fields on my form as it goes through the loops

Static Sub DATEPD2_GotFocus ()
If NTZ(ZZ) = 0 Then
Exit Sub
End If
NOOFP1 = NTZ(NOOFPAYMENTS1)
NOOFP2 = NTZ(NOOFPAYMENTS2)
DEFP = NTZ(DEFERREDPAYMENT)
TOTP = NTZ(ZZ): J = 1: I = 1
Dim AMTDUE(38)

If DEFP > 1 Then
For J = 2 To DEFP
AMTDUE(J) = DEFERREDAMOUNT
Next J
J = DEFP: I = DEFP
End If
J = J + 1
I = I + NOOFP1

For K = J To I
AMTDUE(K) = AMOUNTOFPAYMENTS1
Next K
K = DEFP + NOOFP1 + 1
I = TOTP

If NOOFP2 > 0 Then
For L = K To I
AMTDUE(L) = AMOUNTOFPAYMENTS2
Next L
End If
End Sub

It is a field name but Me![NameOfField] does not work. I believe the problem is with the loop variables of J, K and L. I want AMTDUE(K) to be field AMTDUE2..3..4 and so on, these are the field names on my form
(AMTDUE1 thru AMTDUE38). If I replace the variable with a number (2..3..4) then it returns the value to my form with no problem. I tried making a variable like M = "AMTDUE" + K, but then M is still not recognized as the field name even though it does make M=AMTDUE2 or whatever, which is the name of my field. I am really frustrated now can you please help.

I am trying to return values to a payment schedule. I have never written a procedure in a module before. I know the math is right and should return the proper values. I still have not done the part for the dates and balances due but thought if I could get this part going then I would be able to add these parts based on the solution. I really have no idea what I am doing other than the math portion and that the loops are the way to make the procedure do the heavy work for me.

Sorry to be so ignorant on the subject and need a simplistic answer (which it may not be). In advance thank you for any help you can give.
 
Would if I could...Looking into it a bit more..I'll try and get back to you...

Paul
 
I suppose that nobody answered your question so far because this code is causing eye-cancer ;-).

I understand your question as follows:
How can I store the values from variables from inside a procedure in a table.

The answer is: use recordsets (DAO or ADO, see Online-Help for details).
Once you modify the table on which the form is based you need to requery the form in order to see the modified data.
I strongly recommend that you simplify the structure of your code and that you use friendly names for your vars and procedures.
 

Users who are viewing this thread

Back
Top Bottom