Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Posts
    38

    Question Unanswered: Run a query without opening it

    Is it possible to run a query without having to open it I have about ten queries I need to run upon opening a file at the moment I am using OpenQuery and then Close to close it so when someone opens a file it also flashes quickly query windows ten times which is very poor development and not great on the eyes with all the flashing I want it to run but not do this at all just run in the background without having to be physically opened. Is this possible?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Docmd?
    Docmd.runsql?

  3. #3
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    Use ADO to create a recordset for each of the queries. See the help file on how to use ADO
    Justin

  4. #4
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Quote Originally Posted by LisaWoodward
    Is it possible to run a query without having to open it I have about ten queries I need to run upon opening a file at the moment I am using OpenQuery and then Close to close it so when someone opens a file it also flashes quickly query windows ten times which is very poor development and not great on the eyes with all the flashing I want it to run but not do this at all just run in the background without having to be physically opened. Is this possible?
    Use the SetWarnings command in either macros or VBA i.e. SetWarnings to false at the beginning of your query run then SetWarnings to true at the end.

    Chris

  5. #5
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404
    As a short term measure (until you rewrite your code) you could try:

    Application.Echo = False

    in the code before the queries open, and

    Application.Echo = True

    in the code when the queries close. Be careful to put the second line in an on error goto routine.

    It stpops the screen from flashing. I have used it a couple of times, and it's given me a sort of breathing space so that the databas looks OK, while I desperately rewrite the code so that the reason for the flashing goes!


  6. #6
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    what about
    currentdb.execute([SQLCode] or [QueryName]).
    As long as you don't have to pass parameters to the query it works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •