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

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?

MichaelDJ
MichaelDJ2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hongjunCommented:
you need to do a Set CurrentDb = New .....
0
hongjunCommented:
instantiate the object
0
Alan WarrenApplications DeveloperCommented:
try:

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

CurrentProject.Connection.Execute strSql ,, adExecuteNoRecords


or:

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



Alan

0
harfangCommented:
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MichaelDJ2000Author Commented:
harfang

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

MichaelDJ
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.