[AccessD] Feeding an paramarray to a paramarray

jwcolby jwcolby at colbyconsulting.com
Wed Mar 12 12:04:09 CDT 2008


Good idea but... the ParamArray can be anything from collections to strings
to integers etc.  Split expects a string, not an array of variants.

John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Wednesday, March 12, 2008 10:36 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Feeding an paramarray to a paramarray

Could you use split to dismantle the paramarray and pass that result to your
LogGrpMembers?

Charlotte Foust

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, March 12, 2008 3:23 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Feeding an paramarray to a paramarray

Paramarrays are very useful.

function ListGrpMembers(ParamArray GrpMembers() as variant) dim varGrpMember
	for each varGrpMember in GrpMembers
		debug.print varGrpMember
	next varGrpMember
end function

ListGrpMembers "John", "Mary", "Robbie", "Allie"

Paramarrays allow you to feed a variable number of values into a function,
and then easily manipulate the array that they are placed in using a for
each iterator.

The problem lies if you then need to feed that array off to another
function.

function LogGrpMembers(Paramarray GrpMembers() as variant) end function

Using a function as shown above doesn't work.  If you pass the
GrpMembers() array assembled in ListGrpMembers into LogGrpMembers you get a
runtime error.

I have "solved" this problem by unpacking the array into a collection and
passing the collection into the next function.  

function LogGrpMembers( GrpMembers as collection) end function

function ListGrpMembers(ParamArray GrpMembers() as variant) dim varGrpMember
dim colGrpMembers as collection
	set col
	for each varGrpMember in GrpMembers
		colGrpMembers.Add  varGrpMember
	next varGrpMember
	LogGrpMembers colGrpMembers
	
end function

While that works, it is cumbersome and there are times where you would
really like the second function to be a ParamArray as well, perhaps so that
it can be called directly if required.

Am I missing something?  Is there a syntax for passing a paramarray into
another paramarray?

John W. Colby
Colby Consulting
www.ColbyConsulting.com 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list