Quick Q about passing recordsets to functions (vba, DAO)

HalloweenWeed

Member
Local time
Today, 09:50
Joined
Apr 8, 2020
Messages
220
Hi,
I just ran into the situation where I may want to pass a couple of recordsets to a function/subroutine. Pardon me for asking, but when I google this I get hundreds of misses on the hits.
When you pass a recordset to a function/subroutine, I understand this is a copy, not a single shared recordset.
Does the recordset retain the same current record?
Do the bookmarks pass with the recordset?
I.e. if I set a bookmark before passing, will the function/subroutine be able to use it to set the proper active record?
If the recordset is created with SQL containing "ORDER BY," does the sort order remain in the copy?
I.e. if the sort order sets a specific record as the first record, is that record the first record on the copy?
Thank you in advance.
 
When you pass a recordset to a function/subroutine, I understand this is a copy, not a single shared recordset.
That may not be entirely correct. It's possible it's actually a reference or pointer to the actual recordset object. In which case every property it has will be the same and can be changed.
 
When you pass a recordset to a function/subroutine, I understand this is a copy, not a single shared recordset.
This is incorrect. If you pass a recordset to another procedure it is actually the very same recordset.
 
This is incorrect. If you pass a recordset to another procedure it is actually the very same recordset.
That would simplify things quite a bit, as long as I am careful that the subroutine/function doesn't leave any crucial settings modified.
 
When you pass any object you pass a pointer to the object. You do not pass the entire house only the address to the house. If you pass byRef you pass the pointer (address), if you pass byVal you pass a copy of the pointer. You never pass a "clone" of the object.
 
When you pass any object you pass a pointer to the object. You do not pass the entire house only the address to the house. If you pass byRef you pass the pointer (address), if you pass byVal you pass a copy of the pointer. You never pass a "clone" of the object.
Thank you, guys.
 
Since the "passing" around tends to stay in the same module, I create private variables in the header of the module to hold the recordset. That way, all procedures in the module can work directly with the same recordset.
 
Since the "passing" around tends to stay in the same module, I create private variables in the header of the module to hold the recordset. That way, all procedures in the module can work directly with the same recordset.
Oh, I see, nice tip :) TY
 

Users who are viewing this thread

Back
Top Bottom