Object required

A

AngiW

I don't know why i'm having so much problem with this code but i keep getting
Run-time error '424':
Object required....why?? I read the help and the only i can think of is that
i'm not referring to the table right.

If table![Accrual Main].lastupdated <= Now() Then
 
W

Wayne Morgan

You can't refer to a table that way. Which record from the table should it
pick? You need to open a recordset first and move to the desired record or
refer to a value on the form, which will give you the value for the current
record.
 
A

AngiW

I need it to scan all the records of the database and update them if it meets
the if requirement. I now assume that i'm doing this the wrong way. Do i need
to use a do...loop and if so, how do i refer to each record?
 
W

Wayne Morgan

If you need it to scan all the records of the table then update based on
criteria, you may want to check out running an Update Query. This would
normally be the quickest way to handle this. You can run the query manually
or through code.
 
A

AngiW

I am running an update query through code. That's the "then" part of the if
that i can't get working (see end of statement...why? post). Do i use a
do...loop or just reference a recordset? Can you tell i'm confused?!
 
T

Tim Ferguson

(e-mail address removed) (AngiW) wrote in
I am running an update query through code. That's the "then" part of
the if that i can't get working

It's still faster, safer, easier to debug and more portable to use a query

strSQL = "UPDATE [Accrual Main] " & _
"SET Something = Something + 27 " & _
"WHERE LastUpdated <= NOW();"


db.Execute strSQL, dbFailOnError

and if you create it as a QueryDef, then it will run faster by a factor of,
at least, 0.04%...


Hope that helps


Tim F
 
W

Wayne Morgan

Tim gave a good example. If you need further help you'll need to post the
rest of the code for this section so that we can see everything you're
trying to do and how you're doing it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top