dbTalk Databases Forums  

access2007, sql 2005 - Object invalid or no longer set

comp.databases.ms-access comp.databases.ms-access


Discuss access2007, sql 2005 - Object invalid or no longer set in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
ron paii
 
Posts: n/a

Default Re: access2007, sql 2005 - Object invalid or no longer set - 09-08-2011 , 07:23 AM






"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote

Quote:
"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j452dt$lqm$1 (AT) dont-email (DOT) me:



"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote in message
news:Xns9F55A957D54D0f99a49ed1d0c49c5bbb2 (AT) 88 (DOT) 198.244.100...
"ron paii" <none (AT) nospam (DOT) com> wrote in
news:j3qi51$opb$1 (AT) dont-email (DOT) me:

If (frm.RecordSource <> strsql) Then
frm.RecordSource = strsql
On Error GoTo fErr

set rsClone = frm.RecordsetClone

If (Not (rsClone .EOF)) Then
rsClone .MoveLast
lngCount = rsClone.RecordCount
rsClone .MoveFirst
End If
set rsClone = Nothing
Else
frm.Requery
End If

This makes me crazy. There is simply NO REASON to set a variable
pointing to the RecordsetClone -- just use a WITH structure and
save the extra work:

If (frm.RecordSource <> strsql) Then
frm.RecordSource = strsql
On Error GoTo fErr

With frm.RecordsetClone
If (Not (.EOF)) Then
.MoveLast
lngCount = .RecordCount
.MoveFirst
End If
End With
Else
frm.Requery
End If

That's true, but I normally do more with the clone. So I find it
easer to use a variable.

What are you doing that makes it easier? What exactly are you doing
with the form's RecordsetClone?

That is, as opposed to the Clone of any old Recordset, which
definitely requires a variable assignment to be used?

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
One example is a Gantt chart form, which allows the user to update the
schedule by editing the chart. The form is based on a temp table. The on
Open event needs to open a number of record sets including a recordsetclone,
which are closed when the form is closed.

Reply With Quote
  #12  
Old   
James A. Fortune
 
Posts: n/a

Default Re: access2007, sql 2005 - Object invalid or no longer set - 09-08-2011 , 09:31 PM






On Sep 7, 7:41*pm, "David-W-Fenton" <NoEm... (AT) SeeSignature (DOT) invalid>
wrote:
Quote:
"ron paii" <n... (AT) nospam (DOT) com> wrote innews:j4523k$joq$1 (AT) dont-email (DOT) me:

I always assumed that RecordSetClone created a new object, being
as I could set multiple references to it and move the cursors
independently.

Hmm. Good point. I'll have to meditate on that one.

But it's very clearly not a new object -- it exists already, since
you don't have to initialize it in order to use it.

Of course, maybe when you're assigning it to a variable you are
getting a copy instead of the original object? I'll have to think a
bit on how to test that out...

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
contact via website only * *http://www.dfenton.com/DFA/
How would I implement a RecordsetClone 'Property'? Maybe like:

Dim MyDB As DAO.Database
Dim RecordsetClone As DAO.Recordset

Set MyDB = CurrentDb

Set RecordsetClone = MyDB.OpenRecordset(Me.RecordSource,
dbOpenDynaset)

'Do something with RecordsetClone...

RecordsetClone.Close
Set RecordsetClone = Nothing
Set MyDB = Nothing

I would conclude that the resulting 'RecordsetClone' is a Recordset
object despite A97 Help topic for RecordsetClone Property stating
that:

"The RecordsetClone property setting is a copy of the underlying query
or table specified by the form's RecordSource property."

In other words, the RecordsetClone Property is a SQL reference to a
data object, just like the RecordSource property.

Why not roll your own RecordsetClone whenever you need it? The same
Help topic says:

"For example, you can use the RecordsetClone property when you want to
use a method, such as the FindFirst method, that can't be used with
forms."

Maybe Microsoft thought that it would be common to use a form's
RecordSource like a Recordset and decided to make such use available
with a single statement without having to use a Database variable.
Those are my guesses anyway. Please let me know if your tests prove
otherwise for any version of Access.

James A. Fortune
CDMAPoster (AT) FortuneJames (DOT) com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.