Error: M$ jet database engine does not recognize 'AA0023' as a valid field name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tempalli
    New Member
    • Sep 2007
    • 31

    Error: M$ jet database engine does not recognize 'AA0023' as a valid field name

    I am using M.S.Access as backend database and able to add records from Excel but not able to Edit & Update the specific record from M.s Access with reference to cell value given in excel. Kinldy help me.

    Regards,
    ANANTH
    Last edited by Tempalli; Sep 2 '07, 01:46 PM. Reason: Review
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by Tempalli
    I am using M.S.Access as backend database and able to add records from Excel but not able to Edit & Update the specific record from M.s Access with reference to cell value given in excel. Kinldy help me.

    Regards,
    ANANTH
    If your table and workbook are linked, see the following KB article from microsoft:

    Comment

    • Tempalli
      New Member
      • Sep 2007
      • 31

      #3
      Kindly help me on this code. I am not able to work on this.

      Sub EDIT_UPATE()
      Dim Path As String
      Dim rs As DAO.Recordset
      Dim AccountId As String

      Path = "C:\Documen ts and Settings\Jaganm ohan\Desktop\db 1.mdb"
      Set Db = Workspaces(0).O penDatabase(Pat h, ReadOnly:=True)
      Set rs = Db.OpenRecordse t("Accounts")

      rs.FindFirst "AccountId = 2235" ' DAO only

      If Not rs.NoMatch Then

      rs.Edit ' DAO only
      rs!Amount = 200
      rs.Update
      Else
      MsgBox "Record Not Found"
      End If

      End Sub

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Originally posted by Tempalli
        Kindly help me on this code. I am not able to work on this.

        Sub EDIT_UPATE()
        Dim Path As String
        Dim rs As DAO.Recordset
        Dim AccountId As String

        Path = "C:\Documen ts and Settings\Jaganm ohan\Desktop\db 1.mdb"
        Set Db = Workspaces(0).O penDatabase(Pat h, ReadOnly:=True)
        Set rs = Db.OpenRecordse t("Accounts")

        rs.FindFirst "AccountId = 2235" ' DAO only

        If Not rs.NoMatch Then

        rs.Edit ' DAO only
        rs!Amount = 200
        rs.Update
        Else
        MsgBox "Record Not Found"
        End If

        End Sub
        I am not sure what this has to do with your original question, but see below:
        Code:
        Sub EDIT_UPATE()
        Dim Path As String
        Dim rs As DAO.Recordset
        Dim AccountId As String
        
        Path = "C:\Documents and Settings\Jaganmohan\Desktop\db1.mdb"
        Set Db = Workspaces(0).OpenDatabase(Path, ReadOnly:=False)
        Set rs = Db.OpenRecordset("Accounts", DbOpenDynaset)
        
        
        If rs.RecordCount <> 0 Then[INDENT]
                      rs.FindFirst "AccountId = 2235" ' DAO only
                      If Not rs.NoMatch Then
                          rs.Edit ' DAO only
                          rs!Amount = 200
                          rs.Update
                     Else
                          MsgBox "Record Not Found"
                     End If[/INDENT]
        End If
        rs.Close
        Set Db = Nothing
        Set rs = Nothing
        
        EndSub

        Comment

        • Tempalli
          New Member
          • Sep 2007
          • 31

          #5
          Thanks for your help in this regards, it is working fine.

          I am having a AccountNo in Sheets("Sheet1" ).Range("A1") for "AccountID" ,
          How can i define in this code to edit and update the record.

          Kindly help me if it is possible.

          (Ex.rs.FindFirs t "AccountId = "????" )

          Regards,
          Ananth


          Originally posted by puppydogbuddy
          I am not sure what this has to do with your original question, but see below:
          Code:
          Sub EDIT_UPATE()
          Dim Path As String
          Dim rs As DAO.Recordset
          Dim AccountId As String
          
          Path = "C:\Documents and Settings\Jaganmohan\Desktop\db1.mdb"
          Set Db = Workspaces(0).OpenDatabase(Path, ReadOnly:=False)
          Set rs = Db.OpenRecordset("Accounts", DbOpenDynaset)
          
          
          If rs.RecordCount <> 0 Then[INDENT]
                        rs.FindFirst "AccountId = 2235" ' DAO only
                        If Not rs.NoMatch Then
                            rs.Edit ' DAO only
                            rs!Amount = 200
                            rs.Update
                       Else
                            MsgBox "Record Not Found"
                       End If[/INDENT]
          End If
          rs.Close
          Set Db = Nothing
          Set rs = Nothing
          
          EndSub

          Comment

          • puppydogbuddy
            Recognized Expert Top Contributor
            • May 2007
            • 1923

            #6
            There was a lot more to be done to give youwhat you are looking for. see below:
            Code:
            Sub EDIT_UPATE()
            Dim xl As Object
            Dim xlSht As Object
            Dim xlWrkBk As Object
            Dim xlFilePath As String
            Dim xlFile As String
            
            Dim dbFilePath As String
            Dim rs As DAO.Recordset
            Dim AccountId As String
            Dim Amount As Currency
             
            XlFile = “ xxxx.xls”
            xlFilePath =  “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
            dbFilePath = "C:\Documents and Settings\Jaganmohan\Desktop\db1.mdb"
            
            ‘open excel worksheet object
            Set xl = CreateObject("Excel.Application")
            Set xlWrkBk = GetObject(xlFile)
            Set xlSht = xlWrkBk.Worksheets(1)
            
            ‘open access db table object
            Set Db = Workspaces(0).OpenDatabase(dbFilePath, ReadOnly:=False)
            Set rs = Db.OpenRecordset("Accounts", DbOpenDynaset)
             
            ‘loop until no more cells to copy to table 
            If rs.RecordCount <> 0 Then[INDENT] rs.MoveFirst
                   Do Until. rs.EOF = True
                   rs.AddNew
                        rs.Fields("AccountId") = xlSht.cells(2, "F")
                        rs.Fields("Amount") = Nz(xlsSht.cells(2, "C"),0)         
                  rs.Update
                  rs.MoveNext[/INDENT]
                 Loop
            End If
            
            'Closing excel
             xlWrkBk.Application.Quit
            Set xl = Nothing
            
            'test db table by itself
             rs.FindFirst "AccountId = 2235" ' DAO only
                          If Not rs.NoMatch Then
                              rs.Edit ' DAO only
                              rs!Amount = 200
                              rs.Update
                         Else
                              MsgBox "Record Not Found"
                         End If
            End If
            
            'Closing recordset
            rs.Close
            Set Db = Nothing
            Set rs = Nothing
             
            End Sub
            Last edited by puppydogbuddy; Sep 4 '07, 12:57 PM. Reason: Do Statement on wrong line

            Comment

            • Tempalli
              New Member
              • Sep 2007
              • 31

              #7
              Kindly help me on this code where the error message shows as below.

              The Microsoft jet database engine does not recognize 'AA0023' as a valid field name of expression

              Regards,
              Ananth

              Field Name DataType
              --------------------------------------------------
              AccountID Text
              LOCATION Text

              --------------------------------------------------------------
              Account ID = AA0023
              LOCATION = INDIA
              ----------------------------------------------------------

              Private Sub File_No_AfterUp date()
              Dim Path As String
              Dim rs As DAO.Recordset
              Dim AccountId As String

              Path = "C:\db1.mdb "
              Set DB = Workspaces(0).O penDatabase(Pat h, ReadOnly:=False )
              Set rs = DB.OpenRecordse t("Accounts", dbOpenDynaset)

              If rs.RecordCount <> 0 Then
              rs.FindFirst "AccountId = " & Me.File_No
              If Not rs.NoMatch Then
              rs.Edit ' DAO only
              Me.Location = rs!Location
              Else
              MsgBox "Record Not Found"
              End If
              End If
              rs.Close
              Set DB = Nothing
              Set rs = Nothing
              End Sub

              Comment

              • Tempalli
                New Member
                • Sep 2007
                • 31

                #8
                The Microsoft jet database engine does not recognize 'AA0023' as a valid field name

                Kinldy help me on this code where i am receiving a error message as
                --------- The Microsoft jet database engine does not recognize 'AA0023' as a valid field name of expression --------

                Field Name DataType
                AccountID Text
                LOCATION Text

                Account ID = AA0023
                LOCATION = INDIA


                Private Sub File_No_AfterUp date()
                Dim Path As String
                Dim rs As DAO.Recordset
                Dim AccountId As String

                Path = "C:\db1.mdb "
                Set DB = Workspaces(0).O penDatabase(Pat h, ReadOnly:=False )
                Set rs = DB.OpenRecordse t("Accounts", dbOpenDynaset)

                If rs.RecordCount <> 0 Then
                rs.FindFirst "AccountId = " & Me.File_No ' DAO only
                If Not rs.NoMatch Then
                rs.Edit ' DAO only
                Me.Location = rs!Location
                Else
                MsgBox "Record Not Found"
                End If
                End If
                rs.Close
                Set DB = Nothing
                Set rs = Nothing
                End Sub
                Last edited by Tempalli; Oct 31 '07, 05:54 AM. Reason: Wrong entry

                Comment

                • FishVal
                  Recognized Expert Specialist
                  • Jun 2007
                  • 2656

                  #9
                  Hi, there.

                  String constants should be enclosed with single quotes.
                  rs.FindFirst "AccountId = '" & Me.File_No & "'"

                  Comment

                  • MMcCarthy
                    Recognized Expert MVP
                    • Aug 2006
                    • 14387

                    #10
                    I have merged both posts into one. Please do not double post your question as it causes confusion among the experts when trying to answer your query.

                    ADMIN

                    Comment

                    • Tempalli
                      New Member
                      • Sep 2007
                      • 31

                      #11
                      Originally posted by FishVal
                      Hi, there.

                      String constants should be enclosed with single quotes.
                      rs.FindFirst "AccountId = '" & Me.File_No & "'"

                      Thanks for your help. It is working fine.
                      Regards,
                      Ananth

                      Comment

                      • FishVal
                        Recognized Expert Specialist
                        • Jun 2007
                        • 2656

                        #12
                        Glad you've got it working, Ananth.

                        Best regards,
                        Fish

                        Comment

                        Working...