Access 2007 升级 DAO 引用冲突

发布于 2024-09-11 00:10:18 字数 1806 浏览 3 评论 0原文

我正在将带有 VBA 代码的 Access 97 DB 更新到 Access 2007。当我转换数据库文件(首先从 97 到 2002,然后到 2007)时,VBA 代码使用 Access 2007 引用的 DAO 对象。我的问题具体在于两个引用:“Microsoft DAO 3.6 对象库”和“Microsoft Office 12.0 Access 数据库引擎对象库”。我在网上读到的内容说 ADE 12.0 应该取代 DAO 3.6 参考,并且只需选中 ADE 12.0 框,一切就应该可以工作。由于它们都提供对同名对象的引用,因此不能同时检查这两个引用。但是,当选中 DAO 3.6 框且未选中 ADE 12.0 框时,Access 找不到存在的“frmLogin”表单。如果我取消选中 DAO 3.6 框并选中 ADE 12.0 框,则会收到运行时错误 13:Visual Basic“Err”对象的“类型不匹配”:

Public Function basGetString(ByVal lngStringID As Long, ParamArray varStringArgs() _
      As Variant) As String
     Dim intTokenCount As Integer
     Dim strResString As String

On Error GoTo err_basGetString

    strResString = basLoadString(lngStringID)

    If Not IsMissing(varStringArgs) Then
        intTokenCount = 0

         Do While intTokenCount <= UBound(varStringArgs)
              strResString = basReplaceToken(strResString, _
              m_cstrArgToken, varStringArgs (LBound(varStringArgs) + intTokenCount),_   
              1, 1)

              intTokenCount = intTokenCount + 1
         Loop
    End If

    strResString = basReplaceToken(strResString, m_cstrVBCRLFToken, vbCrLf, -1, 1)
    basGetString = strResString

 exit_basGetString:
      Exit Function
 err_basGetString:
      Err.Raise Err.Number, "basGetString", Err.Description

 End Function

调试器指向倒数第二行:

Err.Raise Err.Number, "basGetString", Err.Description

我有已成功消除记录集对象的歧义,解决了代码中的许多其他引用冲突:Dim rs As DAO.Recordset 或 Dim rs As ADODB.Recordset,但这不适用于 Err 对象。 - 也就是说,我尝试将 Err 对象重写为 DAO Error 对象。我也无法在 VB 编辑器中找到另一个参考来解决此引用错误,但也不会与其他 ADE 12.0 参考发生冲突。所以,我不明白为什么检查 ADE 12.0 框并不能解决我的所有问题。我无法弄清楚如何重写代码以使其引用 ADE 12.0 库。最后,ADE 12.0 参考实际上指向以下文件夹中的 ACEDAO.DLL:C:\Program Files\Common Files\Microsoft Shared\OFFICE12。任何建议将不胜感激。

I am updating an Access 97 DB w/ VBA code to Access 2007. The VBA code uses DAO objects that Access 2007 references when I converted the db files (first from 97 to 2002, then to 2007). My problem specifically is with the two references: "Microsoft DAO 3.6 Object Library" and "Microsoft Office 12.0 Access database engine Object Library." The stuff I've read on the web says that the ADE 12.0 is supposed to supercede the DAO 3.6 reference, and that by just checking the ADE 12.0 box everything should work. Since they both provide references for objects of the same name, these two references cannot be checked at the same time. However, when check the DAO 3.6 box, and leave the ADE 12.0 box unchecked, Access can't find a "frmLogin" form that exists. If I uncheck the DAO 3.6 box and check the ADE 12.0 box, I get a run-time error 13: "type mismatch" for a Visual Basic "Err" object:

Public Function basGetString(ByVal lngStringID As Long, ParamArray varStringArgs() _
      As Variant) As String
     Dim intTokenCount As Integer
     Dim strResString As String

On Error GoTo err_basGetString

    strResString = basLoadString(lngStringID)

    If Not IsMissing(varStringArgs) Then
        intTokenCount = 0

         Do While intTokenCount <= UBound(varStringArgs)
              strResString = basReplaceToken(strResString, _
              m_cstrArgToken, varStringArgs (LBound(varStringArgs) + intTokenCount),_   
              1, 1)

              intTokenCount = intTokenCount + 1
         Loop
    End If

    strResString = basReplaceToken(strResString, m_cstrVBCRLFToken, vbCrLf, -1, 1)
    basGetString = strResString

 exit_basGetString:
      Exit Function
 err_basGetString:
      Err.Raise Err.Number, "basGetString", Err.Description

 End Function

The debugger points the the second-to-last line:

Err.Raise Err.Number, "basGetString", Err.Description

I have been successful disambiguating recordset objects, which resolved many of the other referencing conflicts in the code: Dim rs As DAO.Recordset or Dim rs As ADODB.Recordset, but this hasn't worked with the Err object. -That is, I've tried to rewrite the Err object as a DAO Error object. I also have not been able to find another reference in the VB editor that resolves this referencing error, but doesn't also conflict with the other ADE 12.0 reference. So, I don't understand why checking the ADE 12.0 box doesn't solve all my problems. And I'm having trouble figuring out how to rewrite the code so that it references the ADE 12.0 library instead. Lastly, the ADE 12.0 reference is really pointing to the ACEDAO.DLL in the following folder: C:\Program Files\Common Files\Microsoft Shared\OFFICE12. Any suggestions would be really appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光礼记 2024-09-18 00:10:18

如果您在 A2007 中运行,则需要使用 ADE 参考(其中
只是 DAO 的下一个版本 - 如果您有兴趣,请查看 DLL 名称
不信)。如果此时仍然出现编译错误
检查,那么这意味着它要么没有注册(你可以
使用 regsvr32 手动注册)或者您有不同的参考
问题。请发布您的参考文献列表。我的赌注是几个
它们完全没有必要。另外,如果您正在运行多个
Access版本,您需要让每个版本都完成注册
(即安装)在打开任何文件之前。

– 大卫-W-芬顿 2010 年 8 月 5 日 20:13

If you're running in A2007, you need to use the ADE reference (which
is just the next version of DAO -- have a look at the DLL name if you
don't believe it). If you still get compile errors when that's
checked, then that means it's either not registered (and you could
register it manually with regsvr32) or you have a different reference
problem. Please post your list of references. My bet is several of
them are completely unnecessary. Also, if you're running multiple
versions of Access, you need to let each of them finish registering
(i.e., installing) before opening any files.

– David-W-Fenton Aug 5 '10 at 20:13

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文