By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,617 Members | 1,605 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,617 IT Pros & Developers. It's quick & easy.

Persisting a recordset

JustJim
Expert 100+
P: 407
Having just re-read Adezii's article on the above subject, I thought I'd have a play.

I think there must be a "Reference" that I need to set to use ADODB.Recordset? Otherwise I get a "User-defined type not defined" error.

Jim
Oct 15 '07 #1
Share this Question
Share on Google+
7 Replies


nico5038
Expert 2.5K+
P: 3,072
Try the "Microsoft AcitveX Data Objects" library.
It's selected by default from A2000 or A2003...

Nic;o)
Oct 15 '07 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
Having just re-read Adezii's article on the above subject, I thought I'd have a play.

I think there must be a "Reference" that I need to set to use ADODB.Recordset? Otherwise I get a "User-defined type not defined" error.

Jim
You need a reference to ...

Microsoft ActiveX Data Objects 2.X library
Microsoft ADO Ext. 2.X for DDL and Security
Oct 15 '07 #3

JustJim
Expert 100+
P: 407
You need a reference to ...

Microsoft ActiveX Data Objects 2.X library
Microsoft ADO Ext. 2.X for DDL and Security
Thank you both. (Each individually and together (Dang 20 character limit))

Jim
Oct 15 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Thank you both. (Each individually and together (Dang 20 character limit))

Jim
You're welcome.
Oct 15 '07 #5

JustJim
Expert 100+
P: 407
Having just re-read Adezii's article on the above subject, I thought I'd have a play.

<Snip>

Jim
OK, I'm all Referenced up and playing, one of the immediate uses I thought of was to store a recordset as it was at a particular date and then re-use it even if the data in the database had changed.

when I try the following...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. Dim rsSample As ADODB.Recordset
  3. Dim strFile As String
  4.  
  5. Set rsSample = New ADODB.Recordset
  6.  
  7. 'Construct a file name to use
  8. strFile = CurrentProject.Path & "\Sample.adtg"
  9.  
  10. 'Make sure the file exists
  11.   If Len(Dir(strFile)) > 0 Then
  12.      'Open the recordset from the file
  13.       rsSample.Open strFile, , adOpenDynamic, adLockOptimistic
  14.      'Reconnect the recordset to the database
  15.       rsSample.ActiveConnection = CurrentProject.Connection
  16.      'Make the recordset the recordsource of this subreport
  17.       Set Me.Recordset = rsSample
  18.   End If
  19.   rsSample.Close
  20.     Set rsSample = Nothing
  21.  
  22. End Sub
which is pretty much the code that Adezii posts (except for the cursor type) I get an error at the
Expand|Select|Wrap|Line Numbers
  1.       Me.Recordset = rsSample
line which says Error 2593, This feature is not available in an MDB.

There ain't nuffin' in the help files for the Recordset property saying it's only for an ADP. Is this a problem because of the ADODB.Recordset or am I missing something?

Jim
Oct 16 '07 #6

ADezii
Expert 5K+
P: 8,675
OK, I'm all Referenced up and playing, one of the immediate uses I thought of was to store a recordset as it was at a particular date and then re-use it even if the data in the database had changed.

when I try the following...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. Dim rsSample As ADODB.Recordset
  3. Dim strFile As String
  4.  
  5. Set rsSample = New ADODB.Recordset
  6.  
  7. 'Construct a file name to use
  8. strFile = CurrentProject.Path & "\Sample.adtg"
  9.  
  10. 'Make sure the file exists
  11.   If Len(Dir(strFile)) > 0 Then
  12.      'Open the recordset from the file
  13.       rsSample.Open strFile, , adOpenDynamic, adLockOptimistic
  14.      'Reconnect the recordset to the database
  15.       rsSample.ActiveConnection = CurrentProject.Connection
  16.      'Make the recordset the recordsource of this subreport
  17.       Set Me.Recordset = rsSample
  18.   End If
  19.   rsSample.Close
  20.     Set rsSample = Nothing
  21.  
  22. End Sub
which is pretty much the code that Adezii posts (except for the cursor type) I get an error at the
Expand|Select|Wrap|Line Numbers
  1.       Me.Recordset = rsSample
line which says Error 2593, This feature is not available in an MDB.

There ain't nuffin' in the help files for the Recordset property saying it's only for an ADP. Is this a problem because of the ADODB.Recordset or am I missing something?

Jim
Just subscribing for now, but I'll definately drop in later and hopefully we'll get this ironed out.
Oct 16 '07 #7

ADezii
Expert 5K+
P: 8,675
OK, I'm all Referenced up and playing, one of the immediate uses I thought of was to store a recordset as it was at a particular date and then re-use it even if the data in the database had changed.

when I try the following...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. Dim rsSample As ADODB.Recordset
  3. Dim strFile As String
  4.  
  5. Set rsSample = New ADODB.Recordset
  6.  
  7. 'Construct a file name to use
  8. strFile = CurrentProject.Path & "\Sample.adtg"
  9.  
  10. 'Make sure the file exists
  11.   If Len(Dir(strFile)) > 0 Then
  12.      'Open the recordset from the file
  13.       rsSample.Open strFile, , adOpenDynamic, adLockOptimistic
  14.      'Reconnect the recordset to the database
  15.       rsSample.ActiveConnection = CurrentProject.Connection
  16.      'Make the recordset the recordsource of this subreport
  17.       Set Me.Recordset = rsSample
  18.   End If
  19.   rsSample.Close
  20.     Set rsSample = Nothing
  21.  
  22. End Sub
which is pretty much the code that Adezii posts (except for the cursor type) I get an error at the
Expand|Select|Wrap|Line Numbers
  1.       Me.Recordset = rsSample
line which says Error 2593, This feature is not available in an MDB.

There ain't nuffin' in the help files for the Recordset property saying it's only for an ADP. Is this a problem because of the ADODB.Recordset or am I missing something?

Jim
You are creating and destroying a Recordset Variable (rstSample) before the Report has time to display its data. Aside from this, your mysterious Error will still appear. To complicate matters further, this code, except for declaring rstSample Globally and not closing the Recordset in the Procedure, works flawlessly in a Form's Open() Event. It seems as though it will not work within the context of a Report but don't give up hope, I'll look at it later.
Oct 16 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.