No Return Value from Function

  • Thread starter Thread starter montbrae
  • Start date Start date
M

montbrae

Running Access XP.
I have created a Form with 3 unbound text boxes (Text1, Text2, Text3). The
idea being enter a number in Text1 and Text2 and AfterUpdate will call a
function MyTest to add the two numbers and give the result in Text3. I have
run debug and watch windows but the function does not appear to return a
value. Text3 remains null.

I have used functions successfully before in other version of Access and
have many pre-XP databases that still work fine. Is there something I am
missing?

Text2 has an event AfterUpdate as follows.
Private Sub Text2_AfterUpdate()
Text3 = MyTest(Text1, Text2)
End Sub

In Module 1 I have a function MyTest
Public Function MyTest(val1 As Integer, val2 As Integer) As Integer
Dim x As Integer
x = val1 + val2
End Function

Any help would be greatly appreciated.
Regards
Grant
 
The function is not setting its return value.

Try:
Public Function MyTest(val1 As Integer, val2 As Integer) As Integer
MyTest = val1 + val2
End Function
 
Try this:

Public Function MyTest(val1 As Integer, val2 As Integer)
As Integer

MyTest = val1 + val2

End Function

HTH
Steve
 
Back
Top