?
Solved

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

Posted on 2004-11-16
5
Medium Priority
?
685 Views
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?

MichaelDJ
0
Comment
Question by:MichaelDJ2000
5 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 12600575
you need to do a Set CurrentDb = New .....
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12600578
instantiate the object
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12600705
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
 
LVL 58

Accepted Solution

by:
harfang earned 2000 total points
ID: 12600710
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
 

Author Comment

by:MichaelDJ2000
ID: 12601075
harfang

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

MichaelDJ
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

807 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