Gustav Brock
Gustav at cactus.dk
Fri May 26 10:19:53 CDT 2006
Hi Bobby Missed this: public sub Somemethod(byval a as double,byval b as double,byval c as double) You are passing the Values of the fields, not the Field objects themselves. /gustav >>> bheid at appdevgrp.com 26-05-2006 17:06:02 >>> Sorry, forgot to mention that I am using DAO and there is an .edit and .update in there. so we have: public Somefunction(byref rs as recordset) with rs .edit someclass.somemethod !a,!b,!c,!x,!y,!z .update end with end sub Bobby -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Friday, May 26, 2006 10:34 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Byref and recordset field question Hi Bobby You need to Edit and (for ADO) Update the recordset: With rs .Edit someclass.somemethod !a,!b,!c,!x,!y,!z .Update End With /gustav >>> bheid at appdevgrp.com 26-05-2006 16:16:16 >>> 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