?
Solved

Recordset clone error 13

Posted on 2000-01-05
20
Medium Priority
?
320 Views
Last Modified: 2008-02-26
Dim rs As Recordset
Set rs = Me.RecordsetClone

I can not get the above syntax to work with Access 2000. I get an error 13
I tried rs as dbodb.recordset same result. What is is the correct syntax?
0
Comment
Question by:davidpm
  • 9
  • 5
  • 4
  • +1
20 Comments
 
LVL 10

Expert Comment

by:brewdog
ID: 2325867
From what I've heard (unfortunately I don't have A2K yet), it sounds like you need to specify what kind of recordset you want, like so:

Dim rs as ADO.recordset (or DAO.recordset)
set rs = me.recordsetclone

does that work?
0
 
LVL 12

Expert Comment

by:Trygve
ID: 2325983
If you use ADODB, which is part of the the "new world", this is a typical setting for a find something code (in this case, refresh and return to current record):


On Error GoTo ErrorHandling

    Dim MyRecs As New ADODB.Recordset
    Dim myBookmark, CurrentID

    CurrentID = me!cID
    Me.Refresh
    DoCmd.GoToRecord , , acLast
    Set MyRecs = Me.RecordsetClone
    MyRecs.Find "ID='" & CurrentID & "'", , adSearchForward, 1
    myBookmark = MyRecs.Bookmark
    Me.Bookmark = myBookmark

ExitMe:
    MyRecs.Close
    Set MyRecs = Nothing
    Exit Function
   
ErrorHandling:
    Select Case Err
        Case 3021   'Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
            GoTo ExitMe
        Case Else
            msgbox(err & " " & error)
    End Select
    GoTo ExitMe
0
 

Author Comment

by:davidpm
ID: 2326101
Yes thats what I thought should work but the following two lines fail

Dim rs As New ADODB.Recordset
Set rs = Me.RecordsetClone

If I leave out the new keyword it fails also.

It's as if the RecordsetClone is returning some different type of recordset.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:davidpm
ID: 2326110
I also tried

Dim rs As ado.Recordset
Set rs = Me.RecordsetClone


And also
Dim rs As dao.Recordset
Set rs = Me.RecordsetClone

all to no avail

Perhaps there is some environmental thing that needs to be set.

This is just a default install of access 2000 on win 98
0
 
LVL 10

Expert Comment

by:brewdog
ID: 2326148
if you go to Debug | Compile Loaded Modules, does it highlight anything? I think Trygve's syntax is more accurate, with the daodb.recordset or adodb.recordset. If Access chokes when you try to compile those, then I'd go to Tools | References and make sure you have references to ADO and DAO defined in there.
0
 

Author Comment

by:davidpm
ID: 2326268
The following code works. It's not as if adodb is not connected.

Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rst As New ADODB.Recordset
rst.Open "PoNumber", cnn

The following line does not give an error
dim rs as new ADODB.Recordset
This is the line that errors out.
set rs = me.recordsetclone

What references should be in tools, referances.
I have VBA, 9.0 object library, OLE animation and Active x Dataobjects 2.1

Do the following lines execute properly on your sytem in a doubleclick event for example.

dim rs as new ADODB.Recordset
set rs = me.recordsetclone
0
 
LVL 10

Expert Comment

by:brewdog
ID: 2326289
I just checked a couple things, both pretty basic. First, I compiled the code -- that was fine. (Though I don't have ADO, since I'm working in 97; I just declared recordset and it worked.) Second, I played with the recordsource for the form. If that is blank, I get an error, too. Is your form a bound form?
0
 

Author Comment

by:davidpm
ID: 2326306
I really appreciate your efforts but I too have no problem with access 97. I believe this is a access 2000 specific issue. Do you have access to access 2000?

Yes the form is bound. I bet you do not get error 13 though.
0
 

Author Comment

by:davidpm
ID: 2326361
The following code works also so I know the form is OK
    Me.RecordsetClone.findfirst "[PONumber] = " & Me![cboLookup]
  Me.Bookmark = Me.RecordsetClone.Bookmark

0
 
LVL 6

Expert Comment

by:blakeh1
ID: 2326709
You may want to make a reference to the DAO object library, then use the following, after adding this ref using the below code will run without runtime err 13

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
MsgBox rs.RecordCount
Set rs = Nothing
0
 

Author Comment

by:davidpm
ID: 2326756
blakeh1 your code works
I had to make a referance to DAO 3.6 object library.

Does anyone know what the ramificatations of this are.
Is DAO 3.6 concidered current code if so why is it not loaded automatically like adodb.
If it is not is there another way to use recordsetclone that does not require dao 3.6

I want to not use legacy stuff if not necessary.

0
 
LVL 10

Expert Comment

by:brewdog
ID: 2326788
DAO 3.6 is current, but it has limitations for data sources. ADO is Microsoft's new standard because it can use just about anything as a data source. I didn't realize the RecordSetClone was not an ADO method . . . that's both good to know and bad to hear.

Microsoft probably only loads one because if you declare a "recordset" without the ADODB or DAODB object, you can't guarantee which one you'll get. And, as you've seen, they have different methods and all that. If you do leave it loaded (I don't know another way to use RecordsetClone), make sure that your object variables are set to ADO-type objects.
0
 

Author Comment

by:davidpm
ID: 2326814
Brewdog
Can you confirm on your system that recordsetclone does not work with adodb. It would seem very odd that a built in function like recordsetclone would be broke out of the box like that.
0
 
LVL 10

Expert Comment

by:brewdog
ID: 2326839
like I said, I don't have Access 2000 on a machine here, so unfortunately I can't help you out with that one.
0
 
LVL 6

Accepted Solution

by:
blakeh1 earned 150 total points
ID: 2326874
Actually it seems that to refer to the recordset clone in ado you would actually do

Dim frm As Form
Set frm = Me
With frm.RecordsetClone
    MsgBox .RecordCount
End With
Set frm = Nothing

another way of not using dao is to dim rs as an object instead and let access assign it for you

Dim rs As Object
Set rs = Me.RecordsetClone
MsgBox rs.RecordCount
Set rs = Nothing
0
 
LVL 6

Expert Comment

by:blakeh1
ID: 2326917
actually, just to clarify, the above 2 do not need a reference to the Dao library.
0
 
LVL 6

Expert Comment

by:blakeh1
ID: 2326977
Did some more checking. Found that recordsetclone is not a method or property of adodb. If you use the object browser and search this library only, it will not be found. It is a property of access.form in the Access library. According to help they show an example of
dim rst as recordset
set rst = me.recordsetclone but do not specifically say you need a reference to the dao obj lib
0
 

Author Comment

by:davidpm
ID: 2327102
Blake your dim rs as object does work for me also. It is all very odd. I will try it at my production machine just to make sure but it looks good.
I find the new Access docs very confusing regarding what syntex works with what environment.
0
 
LVL 12

Expert Comment

by:Trygve
ID: 2328358
My code works, but it is based on the form having a SQL Server 7.0 table as its source. I have tested a bit using "normal" tables and here is code that can be used on both (Just change the lines that are commented)

Normal tables: Microsoft DAO 3.6 Object Library needs to be referenced
SQL Server Tables: Microsoft ActiveX Data Objects 2.1 Library needs to be references.

Private Sub Refresh_Click()

On Error GoTo ErrorHandling

    'Dim MyRecs As New ADODB.Recordset ' SQL Server tables
    Dim MyRecs As DAO.Recordset ' "Normal" MDB tables
    Dim myBookmark, CurrentID

    CurrentID = Me!PostCode
    Me.Refresh
    DoCmd.GoToRecord , , acLast ' To be sure that the bookmarks will work
    Set MyRecs = Me.RecordsetClone
   
    'MyRecs.Find "PostCode='" & CurrentID & "'", , adSearchForward, 1 ' SQL Server tables
    MyRecs.FindFirst "PostCode='" & CurrentID & "'" ' "Normal" MDB tables
   
    myBookmark = MyRecs.Bookmark
    Me.Bookmark = myBookmark

ExitMe:
    MyRecs.Close
    Set MyRecs = Nothing
    Exit Sub
     
ErrorHandling:
    Select Case Err
        Case 3021   'Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
            GoTo ExitMe
        Case Else
            MsgBox (Err & " " & Error)
    End Select
    GoTo ExitMe

End Sub

If you can't get it to work, here is some ideas:

- Is your data located in a subform?
- When do you run this code (from where)
- Send the form etc to me and I will have a closer look at it for you and post any findings here. EMail address is in my profile.
0
 

Author Comment

by:davidpm
ID: 2328894
You guys have been great. I've accepted the code that exactly answers my question.
dim rs as object
does not require referancing DAO 3.6
If as object works there must be another more specific syntax that works also but have not found it.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Beware when using the ListIndex and the Column() properties of a listbox in Access 2007.  A bug has been identified in the Access 2007 listbox code which can cause the .ListIndex property to return a -1, and the .Columns(#) property to return a NULL…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question