Randy said:
I have a question - I am trying to speed up my Database and would like
to know which is faster - Dim a database and then use the db.execute method
or just use the docmd.RunSQL Method
I think db.Execute might be marginally faster, but probably
not enough to notice.
It is a good idea to Set db = CurrentDb() because you can
then use the RecordsAffected property to find out how many
records were added, deleted or modified. Certainly it's
somewhat faster to use the Set db ... if you are going to
Execute a sequence of action queries.
Note that Execute requires you to resolve any query
parameters in your code before executing the query. OTOH,
when Access processes the RunSQL method it will take care of
the parameters for you.
All this is mostly irrelevant if you really need to improve
performance. As far as query performance is concerned you
can gain orders of magnitude better improvement by making
sure you have all the Join, Where and Order By fields
indexed (but don't duplicate the automatic index on a
foreign key used in a Relationship). Another important
thing is to remove any **unnecessary** keywords such as
DISTINCT, etc.