Hello,
Would anyone be able to tell me how to sum a string of numbers such as
starting with string 98745, then have it do 9+8+7+4+5 = 33? Thanks!
When you write 'a string of numbers', I'm guessing you don't mean a
string value such as "98745", but a Number value, such as 98745.
They're different.
Copy and past the following function into Module:
Public Function SumNumberValue(ValueIn As Long) As Long
Dim intX As Integer
Dim Total As Integer
Dim intY As Integer
Do While intX <= Len(ValueIn)
intX = intX + 1
intY = Mid(ValueIn, intX, 1)
Total = Total + intY
Loop
SumNumberValue = Total
End Function
You can call it from a query using:
NumberTotal:SumNumberValue([FieldName])
or from an unbound control on a form or report:
=SumNumberValue([FieldName])