Results 1 to 2 of 2
2001-02-15, 02:07 #1LuiGrecoGuest
Passing a RecordSet to a public/private function
I'm wondering what happens if I pass a recordset to a function. Is the currently selected row maintained in the recieving function?
private function1 ()
dim MyRecord as Recordset
set MyRecord = db.OpenRecordset(SomeQuery, dbOpenSnapshot)
MyRecord.Seek "=" Field1, Field2
public function DoSomething(anyRecord as RecordSet)
Is the pointer or current record in DoSomething?
I don't need to update MyRecord just process something based on values of some of the fields.
2001-02-15, 04:00 #2
- Join Date
- Dec 2000
- Sacramento, California, USA
- Thanked 1 Time in 1 Post
Re: Passing a RecordSet to a public/private function
When you pass a recordset, you pass the whole thing. If you want to pass just the current record, create a new recordset object and set it to the original recordset filtered down to the current record. So you might do something like this on an existing DAO recordset, rstCurrent:
Dim rstFiltered as DAO.Recordset
'filter the current recordset
rstCurrent.filter ="[MyKeyField]=" & rstCurrent!MyKeyField
'open a new recordset on the filter
set rstFiltered = rstCurrent.OpenRecordset(dbOpenSnapshot)
Then you could pass rstFiltered to another routine and there would only be a single record for it to work with, so you wouldn't have to worry about a pointer to the current record.Charlotte