UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
> Pass And Return Variables    

The demo in the link below was designed to demonstrate the passing and returning of multiple variables of different data types to/from Functions and Subroutines. It relies entirely on the User-defined Data Type, hereafter and in the code referred to as UDT, which seem to have been long forgotten and replaced with Classes.

It is written in A97 and everything not necessary has been stripped from the ‘References’. No DAO or ADO, no ActiveX Controls…just the bare minimum.


The premise is that we wish to pass and return multiple variables of different data types to/from Functions and Subroutines. It falls between creating a temporary Table, which could bloat the database, and Classes which can be too complex to warrant their creation. It also allows for the re-dimensioning of UDT while still preserving all elements.

How it works…

A Parent structure is created with whatever data types you may require. A Child structure ‘inherits’ the elements (data types) of the Parent as an array.

As such, the Child has only one ‘data type’— That ‘data type’ is an array of the Parent structure. Since the array in the Child has only one dimension, that array can be ReDim’ed while still preserving all the Parent data types.

In effect, we have in the Child an array of pointers to the Parent structure. (Don’t get nervous…we use pointers all the time with Me.)

The code in the demo is written in an ‘exposed’ way. It is written to show the method of referencing the elements in the Parent via the Child. It is therefore more verbose than it need be. Once you get the hang of it you can use the With/End With structure to reduce both the verbosity and typing.

Media:Pass And Return A97.zip

The content of this Access Wiki article was migrated from the UtterAccess FAQA forum and cannot be edited at this time. If you are the original author and would like the article unlocked as a standard wiki article, which enables editing by others, or you are a reader and have identified errors that warrant the removal of this article, please notify the Access wiki moderators.

Original Article by ChrisO

Custom Search

Thank you for your support!
This page has been accessed 11,978 times.  This page was last modified 04:58, 5 February 2012 by Jack Leach. Contributions by Cpetermann and Glenn Lloyd  Disclaimers