Is this a normal behavior in Access? (1 Viewer)

That is impossible to know,
If after the ")" is empty, doesn't it mean there's no retruning value for the function?
I assume As is used for this purpose.

Code:
Function test()              ' has no returning value
vs
Function test() As String    ' has retruning value
 
Function test() ' has no returning value
is equal to
Code:
Function test() as Variant
In principle, functions behave in the same way as variables.
Code:
Dim X as String
Dim Y   ' ... equals: Dim Y as Variant
 
If after the ")" is empty, doesn't it mean there's no retruning value for the function?
No. It's the very definition of a function that is has a return value. If you want a method to not have a return value, you must write a Sub.

Code:
Public Function TestWithNoExplicitReturnValue()
End Function

Public Sub TestTheReturnValue()

    Dim dummy As Variant
    dummy = "Not empty"
    
    dummy = TestWithNoExplicitReturnValue
    
    If IsEmpty(dummy) Then
        MsgBox "dummy is now empty because that was what the function returned."
    End If

End Sub
 
Unfortunately, this is the “comfort functionality” of VBA/VB6 that I would prefer to turn off. :)
 
Slightly weird, that this works without the Set keyword, but that's beyond the scope of the original question.

In the case referenced, the "t = ...." (as opposed to "Set t = ...") is assumed to be referencing the default property of the item to the right of the equals-sign as a possible source for T, which IS declared as a variant. Given the vagaries of late binding, I believe Access compiles the statement and is merely waiting until run-time to see if that right-hand object or variable actually exists when the code is executed.
 

Users who are viewing this thread

Back
Top Bottom