Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a recordset or row to a function

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
US
I have a child table that needs a complex update algorithm run by clicking one of several controls on different forms (and/or when a record is added/edited.)

I open the table (a subset of a much larger one) as a recordset, then assign some variables from the parent table. Now I need to send this recordset to my recordset-processing sub, which needs to determine the type of process to apply, then send the same data one row at a time to the appropriate sub or function to update the table (recordset).

I can't find a reasonable way to pass the recordset as a parameter to a sub or function, and there are too many rows in the table to reasonably pass the data as individual parameters.

I may have left out a step or two, but is there a way to do something like:

private sub loopRecs
dim mydb As CurrentDb()
dim rst as RecordSetClone
dim r,i as long
dim rowDone as Boolean

set rst = mydb("mytable")
r=rst.RecordCount
rst.MoveFirst

For i = 1 To r
' I want to send the row to calcTrans
rowDone=calcTrans(<thisrow of rst>)
' error handling if problem with row
rst.MoveNext
Next

end sub

Function calcTrans(rowpassed As Variant?) AS Boolean
' process row
field1=something
field2=somethingelse
calcTrans = True
end function David 'Dasher' Kempton
The Soundsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top