locked
compile error: Method or data member not found - rst.Edit RRS feed

  • Question

  • I converted my database to 2010 format and now when I click a button I am given a compile error: Method or data member not found. The code stops at rst.Edit in code below.

    Since the button/code work in 2003 (as a mdb) I thought the method used a reference not found in the current version (as compared to the original before conversion). I compared the References and the new (2010) did not have "Microsoft DAP 3.6 Object Library." When I attempted to add it I receive:

    "Name conflicts with existing module, project, or object library"

    The refenrences the 2010 are using
    Visual Basic for Applications
    Microsoft Access 14 Object Libary
    OLE Automation
    Microsoft ActiveX Data Objects 2.1 Library
    Microsoft Office 14 Object Library
    Microsoft Office 14 Access database engine Object
    Microsoft Visual Basic for Applications Extensibility 5.3

    I then assumed that "edit" may not be compatible with 2010 and it didn't display in the intellisense drop down. However editmode did. But it still gives me an error although different: Compile Error: Invalid Use of Property.

    Private Sub PrintApplication_Click()
        
        Dim wrdApp As Object
        Dim wrdDoc As Object
        Dim WordName As String
        Dim rst As Recordset
        Dim docPathname As String
        Dim X As Boolean
        Dim FolderDir As String
        Dim i As Integer
        Dim FromTop As Long
        Dim FileToDelete As String
        Set wrdApp = CreateObject("Word.Application")
        On Error GoTo ErrMsg
        If MsgBox("Save Files Instead of Printing?", vbYesNo) = vbYes Then
            FolderDir = ""
            FolderDir = GetFolder("Please select folder where files are to be saved.")
            If FolderDir <> "" Then
                Do While Dir(FolderDir) <> ""
                  FileToDelete = Dir(FolderDir)
                  Kill FolderDir + FileToDelete
                Loop
            X = PrintIt_Click(False, True, FolderDir)
            MsgBox ("Print Completed")
            End If
        Else
            On Error Resume Next
            Set rst = CurrentDb.OpenRecordset("select * from PrintSections")
            rst.Edit
            For i = 0 To rst.Fields.Count - 1
              rst(i) = True
            Next i
            rst.Update
            rst.Close
            Set rst = Nothing
            FromTop = 450
            CurrentDb.Execute "update attachments set PrintIt = True"
            DoCmd.OpenForm "PrintApplication"
            Call RemoveEmptyAttachment("01", FromTop)
            Call RemoveEmptyAttachment("02", FromTop)
            Call RemoveEmptyAttachment("03", FromTop)
            Call RemoveEmptyAttachment("04", FromTop)
            Call RemoveEmptyAttachment("05", FromTop)
            Call RemoveEmptyAttachment("06", FromTop)
            Call RemoveEmptyAttachment("07", FromTop)
            Form_PrintApplication.PrintIt.Top = FromTop + 275
            Form_PrintApplication.Detail.Height = FromTop + 600
        End If
    ErrMsg:
        If Err.Number <> 0 Then
          MsgBox (Err.Description)
        End If
        On Error Resume Next
    
    End Sub


    jim neal

    Thursday, January 17, 2013 11:07 AM

Answers

  • Hi Jim,

    You have "name conflicts"error because you already have Access Database Engine Object Library, which is just the newer version of the first one, if I'm not mistaken. It relates to Jet vs Ace difference (the name of the database engine).

    Then, you have both ADO and DAO references. Both of them have the object with the name Recordset. Thus I recommend to explicitly declare variables. I mean, change the declaration to Dim rst As DAO.Recordset. 


    Andrey V Artemyev | Saint-Petersburg, Russia
    Russian blog artemyev.biztoolbox.ru

    • Proposed as answer by accessbob-pdx Thursday, January 17, 2013 7:25 PM
    • Marked as answer by JamesLNeal Thursday, January 17, 2013 9:09 PM
    Thursday, January 17, 2013 12:09 PM