- Local time
- Tomorrow, 07:10
- Joined
- Jan 20, 2009
- Messages
- 12,895
How can I to refer to an existing ADO Recordset object variable in a function, given its name as a string?
I have a custom function called from a query. That function includes writing data to an existing fabricated ADO Recordset.
Now I want to generalise the function to write to different recordsets based on an argument.
Clearly, because it comes from a query I can't pass the object reference directly as one would when calling a function from VBA so I must pass the recordset name.
How do I convert that name to a recordset reference inside the function?
If it was DAO I could use the Recordsets collection. I guess I could do the same for the ADO Recordset by adding it to a Collection with its name as the Index when it is created.
However it seems like there should be some straightforward way to refer to the variable by its name. Something like CallByName() but for variables instead of Class Properties and Methods.
I have a custom function called from a query. That function includes writing data to an existing fabricated ADO Recordset.
Now I want to generalise the function to write to different recordsets based on an argument.
Clearly, because it comes from a query I can't pass the object reference directly as one would when calling a function from VBA so I must pass the recordset name.
How do I convert that name to a recordset reference inside the function?
If it was DAO I could use the Recordsets collection. I guess I could do the same for the ADO Recordset by adding it to a Collection with its name as the Index when it is created.
However it seems like there should be some straightforward way to refer to the variable by its name. Something like CallByName() but for variables instead of Class Properties and Methods.