No Return Value from Function

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
 
A

Allen Browne

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
 
S

SteveS

Try this:

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

MyTest = val1 + val2

End Function

HTH
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top