Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Dynamic Queries

Status
Not open for further replies.

TidyTrax

Programmer
Jul 11, 2001
263
0
0
AU
I am using a form to create a series of dynamic queries.

I am using the createQueryDefs method, and then once i am done with the query im using DoCmd.DeleteObject acQuery, to remove the query.

The problem i have is that some of the queries are selects and i cannot delete them cause it opens the query window.

I need a piece of code that says after the query is shut down delete the query, or something that would have a similar effect. I am as always open to suggestions of other ways to do this.
 
2 points:

1. If you are creating a query in code, and you do not need to access it within the user inrterface, then use the syntax:

dim qry as querydef
dim db as database

set db = currentdb
set qry = db.createquerydef("")
qry.sql = ........

'.......code to manipulate qry object

set qry = nothing

Using the empty string as the argument in the createquerydef method creates a temporary query which you do not have to go back and delete.


2. DoCmd.deleteobject should work but an alternative is

dim db as database

set db = currentdb
db.querydefs.delete "qryName"
set db = nothing

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top