Results 1 to 2 of 2

how to automate query running

This is a discussion on how to automate query running within the Microsoft Access forums, part of the Question Forums category; I have inherited a database from a fellow employee. It's in Access and it has ~100 queries that I need ...

  1. #1
    New Member
    Join Date
    May 2006
    Location
    New York
    Posts
    39

    Default how to automate query running

    I have inherited a database from a fellow employee. It's in Access and it has ~100 queries that I need to run. I've already managed to write a simple macro to run a test query
    Code:
    DoCmd.OpenQuery "queryname"
    But now I am faced with copying a 100 names manualy into my code without error so that I can run them all and walk away from my computer/overnight. I.E. create a hundred lines of the same code but with a different name in each.
    I can't seem to find a way to either A) For all queries in this db do {my code} or B) create a txt or list or enumeration of all the queries so I can copy paste into my code. Any help would be appreciated.

  2. #2
    New Member
    Join Date
    May 2006
    Location
    New York
    Posts
    39

    Default run alot of querys auto

    Wow, so that took 4 hours to figure out....
    If anyone is interested the way to run ALOT of querys without having to type in the names or hitting enter every time.
    I ended up coding it in excel so I could close the db and not get authorization issues. For this to work you have to go into Tools-> Referances and make sure all the access related libraries are checked because I still don't know which one exactly these objects reside in. Enjoy

    Code:
    Dim wrkspc As Workspace
    Dim db As Database
    Set wrkspc = CreateWorkspace("WorkSpace", "usrid", "pswd", dbUseJet)
    Set db = wrkspc.OpenDatabase("nameofdatabase.mdb")
    For Each QueryDef In db.QueryDefs
    QueryDef.Execute;
    I am da man!

Bookmarks

Posting Permissions

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


DMCA.com