Re: I want to delete multiple queries. How Do I do it?



Good point, John; however, some operations require a query rather than SQL,
TransferSpreadsheet, for example.
To expand on your thought, using SQL where possible and creating query defs
where needed and deleting them when you are done with them would make sense.

One of the techniques I use where queries are required is to have a template
query that I read into a string, modify the string to include sorting and
filtering, and write it back to the querydef that will be use for the
operation. For example:

strSQL = CurrentDb.Querydefs("qtmpSomeQuery").SQL
....Manipulate strSQL Here
CurrentDb.Querydefs("qselSomeQuery").SQL = strSQL
....Use the Query Here

Now we don't build up a collection of various querydefs.


"John Nurick" wrote:

If there's a need to delete multiple queries under program control, it
sounds as if multiple QueryDefs are being _created_ in the course of
normal operation of the database. Maybe it would be better to avoid this
by building and executing SQL statements on the fly?

On Thu, 1 Jun 2006 13:12:03 -0700, Klatuu
<Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

It would look a lot like VBA :)

But, seriously, folks...
The code will depend on the method you want to use to collect the list of
queries to delete. Post back a description of how you want to do that, and I
will be happy to help.

"John" wrote:

So what would the code be or look like?

"Klatuu" wrote:

The basic idea would be a For Next or a Do Loop with the DeleteObject method
to delete each selected query.

What I don't know is how you will select the queries to be deleted. You
will need a way to select them and put their names in an array and loop
through the array or you could use a form list a list box control, read the
names of all the queries in your database into the row source of the list box
and use the ItemsSelected property collection of the list box to feed the
loop to delete the selected queries.

"John" wrote:

I would like it to be programmatically, manually takes to long....

"Klatuu" wrote:

Manually or programmatically?
Unfortunately, if it is manual, the process is:

Select the query
Press the Delete Key
Repeat until all queries to be deleted are



"John" wrote:

Need to kow how to delete multiple queries.


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

.



Relevant Pages

  • Re: Official Status of SQLServer 2005 ADP
    ... I have said that the support for SQL passthrough ... queries under MDB was bad and worst than the one offered by ADP while you ... > attempt to "pass through" every Access query against a linked ODBC ...
    (microsoft.public.access.adp.sqlserver)
  • Re: "Query Too Complex" Errors
    ... few dozens of queries, in the middle of which there's a long chain of ... we've been having a lot of those "Query Too ... some of the complexity in the SQL ... SQL statement you are working on. ...
    (microsoft.public.access.forms)
  • Re: Dynamic query problem
    ... On Oct 17, 9:41 am, Andy Hull ... If we were to provide a fully featured dynamic query generator we would have ... Provided with already built queries which they can edit ... SQL and see where it is the same as for the other queries and where it ...
    (microsoft.public.access.queries)
  • Re: CONTAINS performance
    ... mark, FTS needs to be very carefully tuned to achieve second response times, ... see SQL Server 2000 BOL title "Full-text Search Recommendations" for more ... When you include the "TOP 100" in your query, you are in fact limiting the ... valid for SQL queries, they often do not apply to FTS queries because the FT ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Populating a list -- learning Access
    ... It is kinda funny -- I started using databases in the early 80's with dBase and, for years, never knew that I knew SQL! ... If you are on a form or report, the most important property is the NAME, because that is how you refer to it in code. ... I don't mean to skip your responce below, but thanks to your help with SQL, I was able to get the query to pull the info the way I needed. ... Queries (just shows the QBE grid for convenience -- ...
    (microsoft.public.access.forms)