Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error Method not found

Status
Not open for further replies.

theSizz

Technical User
Apr 22, 2002
93
0
0
US
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.
 
The standard way of resolving such, since MS introduced ADO at some point of time in 1999, is to be explicit in the declarations:

[tt]Dim rs As DAO.Recordset[/tt]

The recordset type you've got, is probably ADO, since ADO does not have an .Edit method.

Roy-Vidar
 
Thanks Roy
declaring it as:
Dim rs As DAO.Recordset solved it.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top