Access开发平台--登陆时如何自动引用DAO3.6方法
时 间:2017-02-15 10:19:48
作 者:杜超 ID:16058 城市:江阴
摘 要:经常遇到'Mid'函数未定义,DAO类型未定义等错误一般手动重新引用DAO3.6就可以解决问题了。那如何让平台自动引用呢,方法如下
正 文:
将以下代码复制替换到模块basRDPStartup中就行了
Option Compare Database Option Explicit Public Function ReAddRDPLibReference() On Error Resume Next Dim strMDE As String: strMDE = CurrentDb.Properties("MDE") On Error GoTo ErrorHandler If strMDE = "T" Then Exit Function Dim strLib As String Dim strDao As String #If Win64 Then strLib = CurrentProject.Path & "\RDPLib.x64.ucl" #Else strLib = CurrentProject.Path & "\RDPLib.x86.ucl" #End If If FolderExists("C:\Windows\SysWOW64") Then strDao = "C:\Program Files (x86)\Common Files\microsoft shared\DAO\dao360.dll" Else strDao = "C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll" End If Dim ref As Reference For Each ref In Application.References On Error Resume Next Dim strRef As String: strRef = "" strRef = ref.FullPath On Error GoTo ErrorHandler If strRef Like "*\RDPLib*.ucl" Then Application.References.Remove ref ElseIf strRef Like "*DAO*" Then Debug.Print strRef Application.References.Remove ref End If Next Application.References.AddFromFile strLib Application.References.AddFromFile strDao ExitHere: Exit Function ErrorHandler: MsgBox Err.Description & vbCrLf & strLib, vbCritical, "Reference Error #" & Err End Function Function FileExists(ByVal strFile As String, Optional bFindFolders As Boolean) As Boolean Dim lngAttributes As Long lngAttributes = (vbReadOnly or vbHidden or vbSystem) If bFindFolders Then lngAttributes = (lngAttributes or vbDirectory) Else Do While Right$(strFile, 1) = "\" strFile = Left$(strFile, Len(strFile) - 1) Loop End If On Error Resume Next FileExists = (Len(Dir(strFile, lngAttributes)) > 0) End Function Function FolderExists(strPath As String) As Boolean On Error Resume Next FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory) End Function
Access快速开发平台QQ群 (群号:321554481) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 【Access高效办公】如何让vb...(04.11)
- 仓库管理实战课程(10)-入库功能...(04.08)
- Access快速开发平台--Fun...(04.07)
- 仓库管理实战课程(9)-开发往来单...(04.02)
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)