I started working on creating a custom function in Access 2010, using the VBA Editor, but I keep getting an Expected End of Statement Error.
Here's the code:
Public Function getPayTotal(ByVal StudentID As Long) As Long
Return StudentID
End Function
I have absolutely no idea why this isn't working. The debug keeps sending me back to the Return StudentID line. Am I over looking something incredibly simple?
Not return:
Public Function getPayTotal(ByVal StudentID As Long) As Long
getPayTotal = StudentID
End Function
You can call the function like so:
Sub theFunction
getPayTotal 21
''Or
Call getPayTotal(21)
''Or
r = getPayTotal(21)
End Sub
In other words, be careful with the parentheses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With