Getting "Object Required" error message when running CurrentDB.Execute statement

Posted on 2004-11-16
Last Modified: 2010-05-18
Code is below:  

   DoCmd.OpenQuery "ADT-forUpdate_2", acViewNormal, acEdit  'Creates a table from a query
   DoCmd.OpenTable "Original_Begin_Balance", acViewNormal, acReadOnly  'Table created by query
   DoCmd.GoToRecord acTable, "Original_Begin_Balance", acFirst
   DoCmd.GoToControl "Begin Balance"   'Will set temporary value to this begin balance
   CurrentDb.Execute "UPDATE OrigBeginBalCache SET OrigBeginBal = " _
      & Original_Begin_Balance.[Begin Balance], dbFailOnError

Any ideas why i'm getting the ""Object Required" error message?

Question by:MichaelDJ2000
    LVL 33

    Expert Comment

    you need to do a Set CurrentDb = New .....
    LVL 33

    Expert Comment

    instantiate the object
    LVL 26

    Expert Comment

    by:Alan Warren

    Dim strSql as String
    strSql = ""UPDATE OrigBeginBalCache SET OrigBeginBal = " _
          & Original_Begin_Balance.[Begin Balance]

    CurrentProject.Connection.Execute strSql ,, adExecuteNoRecords


    Dim strSql as String
    strSql = ""UPDATE OrigBeginBalCache SET OrigBeginBal = " _
          & Dlast("Begin Balance","Original_Begin_Balance")


    LVL 58

    Accepted Solution

    Missing quotes in:
       CurrentDb.Execute "UPDATE OrigBeginBalCache SET OrigBeginBal = " _
          & " Original_Begin_Balance.[Begin Balance]", dbFailOnError

    Or, more likely, you are trying to retreive the information visible on screen in the open table. There is no way to do that, except if the table is includes as subform in a form.

    What you are lookin for is this (or something like that)

        With CurrentDB.OpenRecordset("Original_Begin_Balance", dbOpenDynaset)
            curFirstBalance = ![Begin Balance]
            ' do something here with the first balance of the table...
        End With

    Actually, you might continue from there and loop through the entire table. I provided an example in http:Q_21207932.html#12597485 if you recall :)

    Good Luck

    Author Comment


    Your method works. Is what I was looking for.  thanks!


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now