[AccessD] Can a function return an object?

John Colby jwcolby at gmail.com
Fri Mar 17 15:13:11 CDT 2023


Technically speaking a function returns a *pointer* to an object.  It is a
32 bit or 64 bit number which points to an address in memory where the
actual instance of the object resides.  This is an important distinction
because functions can accept and return actual instances of *some* things
such as an integer variable.  But AFAIK objects are never passed, only
pointers to objects are passed.

IIRC the function is defined with the 'as' keywords after it, followed by
the type of thing being returned, in this case an object of type form.

Function fFrm() As Form

    Set fFrm = Forms("frmLocation")

End Function

Now in the debug window:

?ffrm.Caption
frmLocation

On Fri, Mar 17, 2023 at 5:56 AM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> Can a VBA function return an object, such as a form or DAO.database?
>
> Can a function return a collection?
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list