在Vista和Win7下使用多个Access版本时出错

微软Access的漏洞

Flaws in Microsoft Access

艾伦·布朗2006年12月报告,2010年8月更新

Provided by Allen Browne, December 2006. Updated August 2010.


在Vista或Windows7下使用多个版本的Access引发的错误

Errors using multiple versions of Access under Vista or Windows 7

如果你在Windows Vista或以后的Windows版本上安装了多个Microsoft Access版本。那么当你在Microsoft Access 2000、Microsoft Access 2002和Microsoft Access 2003上运行代码时会报错。

If you install multiple versions of Access under Windows Vista or later, you receive errors when you run any code in Access 2000, 2002 and 2003.

例如说,如果界面在当前事件中包含可执行代码会不能打开并报如下错误:

For example, if a form has code in its Current event procedure, it fails to open with this message:

被设定为当前事件的代码表达式产生了如下错误:

The expression On Current you entered as the event property setting produced the following error:
类或对像不支持该事件。
Object or class does not support the set of events.

更早版本的Microsoft Access情况有所不同。例如,Microsoft Access 97会出现以下错误:

Earlier versions do not run at all. If you switch to Access 97, you are told:

Microsoft Access 不能启动。

Microsoft Access can’t be started.
Microsoft Access 不能在注册表中被初始化。
Microsoft Access was unable to initialize the Windows Registry
重装Microsoft Access。
Rerun Microsoft Access or Microsoft Office Setup to reinstall Microsoft Access.

切换到最新的Microsoft Access版本则一切正常(重装过后)。

Switching to the lastest version of Access works (after the pause for reinstallation.)

原因

Cause

你所打开的Access需要相应的Access对象库和Office对象库支持。而在Vista下,程序是没有干预注册表的权限的。

The Access and Office library references are adapted to the version of Access you open. Under Vista, programs do not have the privilege to alter the registry.

所以Access会使用最后安装的对象库去编译代码。而代码在错误的对象库版本下是不能被编译的。所以就发生了以上所描述的错误。

Access therefore runs with the last registered library. The code cannot compile using the library of the wrong version, so no code works.

下面的屏幕截图是从Microsoft 2000中获得的。Microsoft 2000应该对应9.0 对像库(以后的版本不会使用这个对象库,但是能兼容它),但是这里却错误的试图使用12.0对像库(Access 2007以后的版从使用这个对像库。)

The screenshot is from Access 2000. It correctly identifies the Office 9.0 library (since no database had been opened using the Office library), but incorrectly attempts to use the Access 12.0 library (since Access 2007 was used previously.)

如果相知道各个版本的Microsoft Access所对应的对象库版本,请参阅:

To read more about what References are and which ones apply to each version of Access, see Solving Problems with Library References.

解决方案

Workarounds

这里有一些必须做的事情。

Here are some alternatives.

第一点:修改注册表

Option 1: Modify the Registry

根据Access微软最有价值的砖家->格雷厄姆 Mandeno(NND 在线找了N多字典也没找到这个姓氏怎么译,太奇葩了!你妹的……)建议我们要修改注册表,所以我们需要管理员权限。以下是操作步骤:

This suggestion from Graham Mandeno (Access MVP) modifies the Windows Registry so that Access always runs with full permissions:

  1. 打开注册表(使用RegEdit命令——脱裤子放那个啥,地球人都知道该怎么做)
  2. 找到以下键:
    HKEY_CLASSES_ROOT\TypeLib\{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}\9.0
  3. 右击该键,在右键菜单中选中权限项。
  4. 在权限对话框中,选择Users用户组。
  5. 给Users用户组以所有的权限。
  1. Start RegEdit.
  2. Find the key:
    HKEY_CLASSES_ROOT\TypeLib\{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}\9.0
  3. Right-click it, and choose Permissions.
  4. In the Permissions dialog,      select the Users group.
  5. Under Permissions for      Users check the Allow box beside Full Control.

虽然这只是2000的对象库,但是其他高版本的Access都是对它兼容的。

Even though the key refers to 9.0, the solution applies to all versions from Access 2000 onwards.

(关于修改注册表还是那句话——一定要小心再小心。)

(As always, exercise care when editing the registry.)

第二种选择:在管理员权限下运行

Option 2: Use Run As Administrator

建立一个快捷方式使msaccess.exe在管理员权限下运行。这样Access就能自己在启动时修改注册表了。

Create a shortcut to run each msaccess.exe as an administrator. This allows each version to register itself on start-up.

以下是具体做法:

To set up this workaround:

  1. 删除原有的Access图标(这些图标不会让Access在管理员权限下运行)。
  2. 为各个版本的msaccess.exe创建新图标。(在文件夹中右键拖动它们。)
  3. 右击快捷方式,选择属性页,单击高级按钮。选择在管理员权限下运行。
  1. Delete any shortcuts created      by installing Office. (These lack the Run As Administrator option.)
  2. Create shortcuts to      msaccess.exe from each version of Office. (Right-drag them from the folder      in Computer.)
  3. Right-click the shortcut,      and choose Properties. Click the Advanced button. Check the Run      as Administrator box.

每次启动Access时会弹出一个对话框让你确认让Access在管理员权限下运行。

Each time you start Access, you will need to click the Continue button in the User Account Control warning dialog.

Access 2007是个例外,你不需要这样做。

For Access 2007, you can use a normal shortcut, i.e. Run As Administrator is not needed for this version.

注意:在这样做了以后,你可能需要在各种版本的Access间切换以保证Access能在注册表中注册正确的对象库。

Note: after you make this change, you may need to switch to another version and switch back before Access will register the correct library.

第三种选择:屏蔽安全控制

Option 3: Remove the Safety

最简单的方法(也是最不安全的方法)是使用管理员帐号的权限关掉用户控制。

The simplest (and least safe) workaround is to disable UAC, and use an administrative account.

警告:这样做对Windows的安全是非常危险的。恶意软件在Window XP和更早的Window版本上会自动安装。

Warning: This degrades the security of Windows. Malware can install itself as in Windows XP and earlier.

这个方法是在假设你已经以管理员账户登录了系统,后按如下步骤执行。

Assuming you are logged in as a computer administrator, the steps are:

  1. 打开控制面板。
  2. 双击用户账户。
  3. 单击开启/关闭用户控制。
  4. 取消“使用控制保护你的计算机”。
  5. 单击确定。
  1. Open Control Panel.
  2. Double-click User      Accounts.
  3. Click Turn User Account      Control on or off.
  4. Uncheck the box, Use User      Account Control (UAC) to help protect your computer.
  5. Click Ok.

你现在可以在当前系统下自由切换Access了。(这样最终还是不能避免重新安装)

You can now switch Access versions as you could under previous versions of Windows. (This does not avoid the reinstallation delay.)

第四个选择:在每台的机器上运行一个单独的Access版本

Option 4: Use separate machines

在集团环境中,你可能不被允许做以上动作,所以你只能在每台机器上运行一个单独的Access版本。这里的每台机器不一定就是指实实在在的机器。多系统引导的计算机,虚拟机都在这个范畴内。

In a corporate environment, you may not be permitted to use any of the options above, so you will need a separate machine for each version of Access. These “machines” may be virtual PCs, a computer that multi-boots, or physical computers.

Virtual PC 可能是最快速的用来在不同版本间切换的方法。当然如果你使用这个方法就必须明白它的缺点:

The Virtual PC might be the quickest way to constantly swap between versions – once you get it started. Disadvantages:

  1. 它对硬件的依赖相当大(尤其是内存。)
  2. 它的运行速度太慢(模拟器还是用来做测试的。)
  3. 它须要附加的Windows许可。
  4. 在Vista及以后的windows版本下Virtual PC需要为不同的版本建立独立的会话。
  5. It requires serious hardware (especially RAM.)
  1. It      is slower to execute. (An emulator is not good for testing.)
  2. It      needs an additional Windows licence.
  3. If      the Virtual PC runs Vista or later, you need separate Virtual PC sessions      for each additional version you support.

第五种选择:不断的重装Office

Option 5: Reinstall Office every time

你可以在需要使用另外一个版本的Access前运行setup.exe重装Office(蛋疼!)。但是,这不能算是个解决方案(人话!)。 这会耗费大量的时间且需管理员权限。

You could run setup.exe from each version of Office every time you wanted to switch versions, but this is no solution. It would require administrative control, be an exercise in frustration with the UAC dialogs, and consume more time than it was worth.

为毛要装多个版本?

Why multiple versions?

如果你问这个问题。那么:这是十分的问题。很有可能没人会对你创建的数据库感兴趣。

If you are asking this question, the entire problem does not apply to you. Chances are, no one else uses the databases you create.

如果你的数据库或终端需要支持不同版本的Access,你可以在不同的版本下这样做:

If you develop databases or support clients who use different versions of Access, you must be able to run multiple versions to:

  1. 创建MDE文件。
  2. 在不同的版本下编译/反编译(以防止含有Bug).
  3. 在你的终端上进行测试追踪。
  4. 从Access 97或更早的版本开始修改你的数据库。
  1. Create MDEs.
  2. Decompile and compile in the      target version (to avoid the weird compilation bugs.)
  3. Test, and trace problems in      the same version as your client.
  4. Make any changes to      databases from Access 97 or earlier.

http://www.allenbrowne.com/bug-17.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值