clone questions

  • Thread starter Thread starter Victoria
  • Start date Start date
V

Victoria

hi

Is 'Set rs = Me.RecordsetClone' exactly equivalent
to 'Set rs = Me.Recordset.Clone'?

I am studying a database that uses both of these.

thanks
 
No, they are not the same thing (though functionally equivalent.) You can
demonstrate this by opening the Immediate Window (Ctrl+G) with a bound form
open, and entering:
? Forms(0).Recordset.Clone Is Forms(0).RecordsetClone

Forms in Access have had a RecordsetClone since at least version 2. Since
Access 2000, forms have had a Recordset property, which you can clone.
Therefore RecordsetClone will work in any version of Access, whereas
Recordset.Clone will work in recent versions.

Both seem to use the same connection to the data. Before you refer to
either, open the Immediate Window and enter:
? dbEngine.Workspaces(0).Databases.Count
The answer is 1 (i.e. only the default database is open.) Referring to
either Recordset.Clone or RecordsetClone causes Access to open a second
database for that data. After referring to both, the count is still 2.
 
Thanks for the clear, educational response.

Allen Browne said:
No, they are not the same thing (though functionally equivalent.) You can
demonstrate this by opening the Immediate Window (Ctrl+G) with a bound form
open, and entering:
? Forms(0).Recordset.Clone Is Forms(0).RecordsetClone

Forms in Access have had a RecordsetClone since at least version 2. Since
Access 2000, forms have had a Recordset property, which you can clone.
Therefore RecordsetClone will work in any version of Access, whereas
Recordset.Clone will work in recent versions.

Both seem to use the same connection to the data. Before you refer to
either, open the Immediate Window and enter:
? dbEngine.Workspaces(0).Databases.Count
The answer is 1 (i.e. only the default database is open.) Referring to
either Recordset.Clone or RecordsetClone causes Access to open a second
database for that data. After referring to both, the count is still 2.
 
hi

Allen - I was interested in what you said about ...
' ? dbEngine.Workspaces(0).Databases.Count'

As I step through code, Databases. Count increments by 1 when I execute code
like
'Set rs = Recordsetclone', just as you said it would. But, why does the
Count NOT decrement by 1 when I execute code like 'rs.Close' followed by 'Set
rs = Nothing'?

just wondering
Victoria
 
You can't (and shouldn't) close the RecordsetClone of the form. If you do,
the line silently fails (as you discovered.)

Access optimises stuff behind the scenes, so it doesn't continually open and
close those connections.

The number should decrease when you close the form.

In this case, I don't think there are and bad effects from wrongly closing
something you did not open (i.e. you merely set a variable to something that
exists, you did not open it.) That's not always the case. If you close the
default workspace, Access silently opens it again, but any forms that were
open now fail if you refer to their RecordsetClone. That's because Access
opens the default database engine again, but not the other ones.
 
Back
Top