Reputation: 399
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?
Upvotes: 6
Views: 19323
Reputation: 91356
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.
Upvotes: 10