gpt4 book ai didi

ms-access - Access 2010 延迟 Autoexec 脚本,直到选择 "enable macros"

转载 作者:行者123 更新时间:2023-12-01 12:42:08 24 4
gpt4 key购买 nike

我在 access 2010 中有一个自动执行脚本,只要用户加载数据库,它就会执行。问题是,在该用户启用宏之前,脚本会失败并给出错误,因为它还不允许运行。

有没有办法延迟自动执行直到选择“启用宏”,然后再触发它?

或者有没有办法在没有 autoexec 的情况下触发代码,这与“启用宏”选择有关?

最佳答案

我找到了 How to force user to deal with the Security Warning when starting Access 2007? ,这让我想到了这个 Microsoft support article .

来自微软文章:

You can use an AutoExec macro to test whether a database is trusted when you open the database. Additionally, the macro can open a form that displays a customized message to users if the database is not trusted. This message lets users know that the database must be enabled or trusted for the code to run successfully.

To create the AutoExec macro and the form, follow these steps:

  1. Create a new form in Design view.
  2. Add a text box or a label to the form, and then type the information that you want to display to the user.
  3. Save and then close the form.
  4. Create a macro, and then name the macro AutoExec.
  5. Show the Conditions column.
  6. Type the following line in the Conditions column:

    CurrentProject.IsTrusted = False

  7. In the Actions column, click OpenForm.
  8. In the Form Name box under Action Arguments, click the form that you created in step 1.
  9. Save and then close the macro.

When the database opens, the AutoExec macro starts and then tests the IsTrusted condition. If the database is not trusted by Access 2007, the macro opens the form that you specified in the "OpenForm" action of the macro.



宏编辑器在 2010 年有所不同,但我能够创建一个 Autoexec 宏来检查 CurrentProject.IsTrusted = False然后显示我的表格。您可以在表单上放置一条消息,告诉用户启用宏。

关于ms-access - Access 2010 延迟 Autoexec 脚本,直到选择 "enable macros",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23406873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com