database 在 Access 2010 数据库中自动查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11677007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:38:09  来源:igfitidea点击:

Automating Queries In An Access 2010 Database

databasems-accessms-access-2010

提问by Intelwalk

I have 6 queries in a db that I'm running each night, saving & publishing the file for use elsewhere. Does anyone know where I can get some direction on setting up to automate this?

我在每晚运行的数据库中有 6 个查询,保存并发布文件以供其他地方使用。有谁知道我可以在哪里获得设置自动化的指导?

采纳答案by Fionnuala

You can run them in VBScript and set that to run with the Task Scheduler. Alternatively, kick off the database with a command line switch: /x macro ( http://support.microsoft.com/kb/209207)

您可以在 VBScript 中运行它们并将其设置为与任务计划程序一起运行。或者,使用命令行开关启动数据库:/x 宏 ( http://support.microsoft.com/kb/209207)

回答by Matstar

3 Easy steps with no coding:

3个简单的步骤,无需编码:

  1. Create a Macro object in Access to run all 6 queries.
  2. Drag the Macro object and drop to the desktop or any folder in Windows Explorer. This creates an "executable" shortcut that opens the database and runs the macro.
  3. Create a new Scheduled Task to launch the shortcut file.
  1. 在 Access 中创建一个宏对象以运行所有 6 个查询。
  2. 将宏对象拖放到桌面或 Windows 资源管理器中的任何文件夹。这将创建一个“可执行”快捷方式,用于打开数据库并运行宏。
  3. 创建一个新的计划任务以启动快捷方式文件。

回答by Christian Specht

  1. Create an autoexec macro in your database.
    This is just a regular macro, but naming it "autoexec" causes Access to execute it when you open the database (press SHIFT to avoid execution).
    In the macro, you can select actions that you want the macro to perform.
    There is an action that runs queries, and one that closes Access.
    I never created a macro in Access 2010, but in Access 2003 the actions are called OpenQueryand Quit.
    --> insert six OpenQueryactions (one for each of your queries) and one Quitaction to close Access in the end.

  2. Run the database with Windows Task Scheduler.
    It will execute the autoexec macro automatically, which will run all your queries and close Access again.

  1. 在您的数据库中创建一个 autoexec 宏。
    这只是一个常规宏,但将其命名为“autoexec”会导致 Access 在您打开数据库时执行它(按 SHIFT 以避免执行)。
    在宏中,您可以选择希望宏执行的操作。
    有一个操作运行查询,一个关闭 Access。
    我从未在 Access 2010 中创建过宏,但在 Access 2003 中,这些操作被称为OpenQueryQuit
    --> 最后插入六个OpenQuery操作(每个查询一个)和一个Quit关闭 Access 的操作。

  2. 使用 Windows 任务计划程序运行数据库。
    它将自动执行 autoexec 宏,它将运行您的所有查询并再次关闭 Access。