Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple arithmetic in access vba

Status
Not open for further replies.

aperture

Programmer
Jul 25, 2001
22
US
hello all

i have a do/while loop in a function that should perform an arithmetic expression and return a resulting value to an access form. the compiler does not like my syntax when i phrase the expression as it appears below. i get the error: 'expected statement, not variable.' i also need to keep a running total of the variable NewD...cant do this until the arithmetic gets done. can anyone help? if you have a
better idea about logic or syntax, im open to it.

Public Function DTotal(curD, curC, curNewD, curNewC)


Let curD = Forms![N_C].D
Let curC = Forms![N_C].C
Let curNewC = curC - curD
Let curNewD = curD - curC


If (curC < curD) Then

Do While (booleanApply = True And booleanXhaust = False)

curD-curC'''''''''''''''''''''''''''''''''''problem expression

intCount 1
Forms![N_C].[Amount_of_D_Remaining].Print curNewD
If Count = 3 Then
Exit Do
End If
Else
If (curD < curC) Then
curC -curD = curNewC
Forms![N_C].[Amount to be Paid].Print curNewC
End If

End Function

Thanks!

jmbt
 
I think that the code below should work for you (not sure). There were multipe syntax errors in your code, you must have done C++ before. I find that I frequently forget the end if's and loop statments in VB because you don't need them in C++. Anyway try the code below and if you have any more questions let me know.
Code:
Public Function DTotal(curD, curC, curNewD, curNewC)

curD = Forms![N_C].D
curC = Forms![N_C].C
curNewC = curC - curD
CurNewD = curD - curC

If (curC < curD) Then
   Do While (booleanApply = True And booleanXhaust = False)
      curD = curD - curC '''''''''problem expression
      intCount 1
      Forms![N_C].[Amount_of_D_Remaining].Print curNewD
      If Count = 3 Then
         Exit Do
      End If
   loop
Else
   If (curD < curC) Then
      curNewC = curC - curD
      Forms![N_C].[Amount to be Paid].Print curNewC
   End If
end if
End Function
The hardest questions always have the easiest answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top