473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Runnning an Action query from code

For many years if I wanted to run an action query from code, I've used code something like this ---
Expand|Select|Wrap|Line Numbers
  1. dim qd as query
  2. dim sSQL as string
  3. dim db as database
  4.  
  5. set db = currentdb()
  6. sSQL = "UPDATE tableA SET field1 = 999 WHERE field2 > 0"
  7. set qd = db.createquerydef("",sSQL)
  8. qd.execute ' sometimes with dbFailOnError
  9.  
  10. qd.close
  11. set qd=nothing
  12.  
etc.....

This creates and runs a temporary query (using DAO. Please don't reply and tell me I should use ADO -- I have my reasons for using DAO)

However over the years as the application has grown and the number of action queries has grown, this method has started to cause trouble. The problem is of course that Access does not reclaim the temporary working space used to create and run the queries. So the database bloats and bloats in normal use. If a user runs the compact function everything is OK again, for a while. But users simply can't be "trained" to do this reliably, and I'd rather sell a product that doesn't bloat itself in the first place, with it's inherent risk of corruption and crashing. (Yes of course my data is split from the app.)

So lately I've been coding differently -- I save all action queries as precompiled queries, and now run them with code something like this --

docmd.openquery "MyActionQuery"

The code is a lot simpler of course. The database is a little bigger initially because of all the pre-compiled queries, but it doesn't seem to bloat as much.
My question is this: What kind of an efficiency hit am I taking by using the "docmd" object? It seems like an unwieldy object with a lot of methods, and I'm not sure if it is the fastest and most efficient way to get the job done for a query.... what do you think? Additionally, as far as I know, no kind of "cleanup" is necessary afterwards, eg no "close" statements or anything like that. Am I right about this?

Derek
Aug 12 '07 #1
1 4167
JKing
1,206 Expert 1GB
Hi there. Have a look at this article it might be what you're looking for: Stored Query vs. SQL Statement

Jared
Aug 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
11
by: Todd Gardner | last post by:
--------------------------------------------------------------- I would appreciate any ideas how to write to the parallel port (Mem 0x378) when runnning WinXP or Mandrake 9.2. In C and LabVIEW I...
1
by: WW | last post by:
How can I turn off the Action Query warnings in a VBA code? Thanks
5
by: deko | last post by:
How to run action query against linked table? I have an Access 2003 mdb with an Excel 2003 Workbook as a linked table. When I attempt to run an action query against the linked table I get this...
3
by: ILCSP | last post by:
Hello, I'm fairly new to the concept of running action pass through queries (insert, update, etc.) from Access 2000. I have a SQL Server 2000 database and I'm using a Access 2K database as my...
5
by: HS Hartkamp | last post by:
Hi all, I am working with fairly large databases (> 500 Mb / < 2,000,000 rexcords), and often need to do action queries on these. I have the feeling that much of the computing power is going...
2
by: paullynch | last post by:
Database: MS Access Subject: SetWarnings macro action I am running macos to run several action queries that replace existing tables with new data based on parameter dates. There are several...
2
by: TroutmansRegistrar | last post by:
I have a web programming task that has me stumped. I hope that one of you could give me some insight or might know someone who could guide me in the right direction. This is the final piece of the...
70
mideastgirl
by: mideastgirl | last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.