Compile Error Method Not Found

theSizz

Registered User.
Local time
Today, 04:07
Joined
Nov 29, 2002
Messages
34
I've converted an .mdb to an .accdb and when I try to run the code listed below, I get a "Compile error method or data member not found" with this line of the code.

Do
rs.Edit

So I went to references and tried to load the DAO 3.6 object library. I got a "Name conflicts with existing module,project,or object library." error.

Here's the code.
Code:
Public Sub SetPantry444()

'Use this routine to increment a field by a set step value

Dim rs As Recordset
Dim startval As Long
startval = 10100
Set rs = CurrentDb.OpenRecordset("tblPricePick")

'Select records to be updated
Set rs = CurrentDb.OpenRecordset _
("SELECT * FROM tblPricePick WHERE AREA444 = '10Pantry' and category <> 'janitorial' and category <> 'paper' ORDER BY [Bin#444]")


    rs.MoveFirst
            
        Do
            rs.Edit
            rs.Fields("Bin#444") = startval 'field to update
            rs.Update
            rs.MoveNext
            startval = startval + 10 'increment step value
        Loop Until rs.EOF
        
             rs.Close
             Set rs = Nothing
       
  
End Sub

It's my understanding that access 2007 transparently uses Microsoft DAO 3.6 Object Library when you open an MDB, and Microsoft Office 12.0 Access database engine Object Library when you open an ACCDB, and since both libraries respond to References("DAO"), your existing code works in both versions.

So what's up with the code not running in the .accdb file?
The code ran fine in the .mdb file before I converted it to the .accdb file.

I guess I could remove the "Microsoft Office 12.0 Access database engine Object Library" and just use the "DAO 3.6 Object Library " but I don't know if that will have any other negative impact on the file.

Any help or insight would be appreciated.
Thanks for reading this.
 
Code:
Dim rs As Recordset
Dim startval As Long
startval = 10100
Set rs = CurrentDb.OpenRecordset("tblPricePick")
Try using

Code:
Dim rs As [COLOR=red][B]DAO.[/B][/COLOR]Recordset

instead
 
Thanks SOS that worked.

It's strange that the original line:

Dim rs As Recordset

ran fine in the .mdb version

Thanks again for the help.
 

Users who are viewing this thread

Back
Top Bottom