简体   繁体   English

使用VBA从Excel删除访问表单

[英]Delete Access form from Excel using VBA

I have 2 forms in an Access database (Access 2007-10) that are feeding records into 2 independent tables. 我在Access数据库(Access 2007-10)中有2种表单,这些表单将记录馈入2个独立的表中。 I am trying to delete these forms using VBA in an Excel workbook. 我正在尝试在Excel工作簿中使用VBA删除这些表单。 My Access database has NO database password but the VBA project in Access HAS a password. 我的Access数据库没有数据库密码,但是Access中的VBA项目有一个密码。 In the Access database I have created a sub procedure (named DeleteAll) which contains the following code for each form: 在Access数据库中,我创建了一个子过程(名为DeleteAll),其中包含每种形式的以下代码:

Docmd.DeleteObject acform, "Name of form"

When I call this code from my Excel VBA, the Access database gives me an error: 当我从Excel VBA调用此代码时,Access数据库给我一个错误:

Run-time error '2017': Microsoft helps protect this Visual Basic for Applications Project with a password. 运行时错误'2017':Microsoft帮助使用密码保护此Visual Basic for Applications项目。 You must supply the password in the Visual Basic Editor before you can perform this operation. 必须先在Visual Basic编辑器中提供密码,然后才能执行此操作。

Funny thing is if I were to delete a query using this method, it gets deleted easily. 有趣的是,如果我要使用此方法删除查询,它很容易删除。 I am experiencing this problem with forms only. 我仅使用表格遇到此问题。

Ms Access query does not have a module attached. Access查询女士没有附加模块。 All forms with VBA module attaches act as a Class. 所有带有VBA模块附件的表格都充当类。 To delete/Edit VBA Module/class you need to supply the password. 要删除/编辑VBA模块/类,您需要提供密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM