[AccessD] Byref and recordset field question

Bobby Heid bheid at appdevgrp.com
Fri May 26 09:16:16 CDT 2006


Hi all,

I am passing a recordset to a sub byref.
In that sub, I am calling a method in a class and passing several of the
fields in the recordset as byref to be like output parameters.  The trouble
is that when the method exits, it is not setting the value in the byref
fields.  
If you look at the variables in the method definition right before the
method exits, it looks like it is set.  But when you look at the value in
the calling sub, it's value has not changed.  

A short example:

set rs=db.openrecordset(strSQL,dbopendynaset)

Somefunction rs	'call the first function, passing recordset byref
...

public Somefunction(byref rs as recordset)

	with rs
        someclass.somemethod !a,!b,!c,!x,!y,!z
	  end with
 
end sub

'x,y,z are the byref "return" variables
public sub Somemethod(byval a as double,byval b as double,byval c as double,
_
	byref x as double,byref y as double,byref z as double)

	'some calcs...
	x=a+1
	y=a*b
	z=2*a

exit sub

If I pass local variables for x,y, and z, everything works properly.  Anyone
know if there is a way to make this work?  There are 5 return parameters and
I'd hate to have to make up 5 variables each time I have to call this
method.

Thanks,
Bobby




More information about the AccessD mailing list