Keeping database windows hidden after running a module

D

DVN

I'm currently running a module that creates a query by
first erasing the original query and rewriting the query.
Everytime it does this, the query becomes unhidden. I
would like to include a line in the module to hide the
query after it is recreated. Does anyone know how to do
that?
 
W

Wayne Morgan

By erase do you mean that you are deleting the query? Do you really need to
or can you just change the SQL property of the querydef?

CurrentDb.QueryDefs("MyQuery").SQL = "SELECT ... etc;"
 
D

DVN

Well, here's an example of what I'm talking about.

DoCmd.DeleteObject acQuery, "FT Failure Classification by
Month Failed"
Set mydb = CurrentDb
'assign current database as database object
Set qdef = mydb.CreateQueryDef("FT Failure
Classification by Month Failed")

I didn't write the code myself, but my interpretation of
this code is that it erases the original query and creates
a new query with the same name. The reason why we do this
is to make sure we pull the latest data from the tables
and that we don't have old data lingering around.
 
J

John Spencer (MVP)

You do realize that a query does not store data. It only gets or manipulates
the data existing in a table.

If you run a Select query and get 25 records,
then add 5 records to the table that meet the query's requirements,
then run the same query again you will get 30 records returned.

If you delete 2 of the records and rerun the query, you will get 27 records.

All this without deleting and then adding in a query.
 
D

DVN

You're right about the query not storing data. What the
original database did was ran a script that created a
query from the records. Since we want to look at a certain
time period, the second part of this program pulls
information from the query we just created to create a
second query with the information that we want. That
information gets sent to premade reports that are setup to
use the format of the second query.

If there isn't a programming command that will do this,
then you don't have to reply back to this message. I had
the feeling that something like this wouldn't be simple.
 
W

Wayne Morgan

Again, I don't see the need to delete the query, just change it to what you
need it to be.
 

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