Where's my .edit method in Access 2010 then?

connexion

Registered User.
Local time
Today, 18:06
Joined
Jul 30, 2003
Messages
72
I feel a bit stupid because i'm sure the answer is right in front of me!

I'm behind the curve and looking into upgrading a 2003 database to 2010.
I have not messed with access for a long time so am out of my comfort zone with 2010.

I've let access save the front and back ends in 2007 format but am finding that my code is stopping for silly reasons. The main one today is that .Edit isn't available to me in the method list (among a few others) and i can't figure out how to get it there?

The code below runs fine in 2003 but not in 2010 because .Edit isn't recognised:

Code:
Public Function fNumberContacts()

    Dim rstContact As Recordset
    Dim cCompanyID As String
    Dim nContactCount As Long
    
    Set rstContact = CurrentDb.OpenRecordset("SELECT * FROM tblCompanyContact ORDER BY CompanyID & Rank;")
    cCompanyID = ""
    nContactCount = 0
    
    With rstContact
        If .RecordCount > 0 Then
            .MoveFirst
            Do While Not .EOF
            
                If !CompanyID <> cCompanyID Then
                    'New Company - reset counter
                    nContactCount = 1
                    cCompanyID = !CompanyID
                Else
                    nContactCount = nContactCount + 1
                End If
                
                'Stamp Rank with unique contact ID
                .Edit
                !Rank = cCompanyID & fPadLeft(CStr(nContactCount), 2)
                .Update
                    
                .MoveNext
            Loop
        End If
    End With
    MsgBox ("Finished!")

End Function

Anyone got any ideas on what i should be looking for? Might this be a references issue?

Thanks
 
Verily verily I say unto you, "Blessed is the man who declares objects with correct library references, for he shall have all intellisense properly loaded lest he shall shrivel in the world of reference ambiguity"
 
I think he is suggesting that your default may no longer be Dao recordsets.
 
Thanks so far.

DAO 3.6 and Office 2014 database engine references seem to conflict so which should i be using going forward?

2003 didn't have a problem with this but i accept things change.

I have replaced all instances of "AS Recordset" with "AS DAO.Recordset" and that seems to work OK now but should i be using the

DAO 3.6 reference or the 2014 engine reference?

Cheers
 
Microsoft Access 2014 Object library will have the DAO inbuilt. So the problem of reference conflict. Leave it as such.
 
I just fired up A2013 and it shows these references

vba
access 15.0
OLE
15.0 access database engine object library


just those settings enable me to

set rst=curretndb.openrecordset("sometable")
rst.edit
etc

so I guess by adding the DAO library you duplicated the DAO reference, which caused the problem, DAO is the default, and I have never had to disambiguate a DAO reference.
 
Thanks for the help chaps.
One thing to note is that i am self tought and therefore don't know what i'm doing! lol
 

Users who are viewing this thread

Back
Top Bottom