gpt4 book ai didi

ms-access - 以编程方式将包含 Access 97 文件的文件夹更新为 Access 2003

转载 作者:行者123 更新时间:2023-12-04 07:04:28 34 4
gpt4 key购买 nike

我有一个文件夹,里面装满了 100 多个 Access97 文件。我需要将它们全部更新到 Access2003。

我可以手动完成,但使用 VBA 可能会快很多。

有没有人会有一个片段可以做到这一点?或者其他的建议?

最佳答案

DBEngine.CompactDatabase olddb, newdb,, dbVersion40
应该管用。

请注意,您需要在单词之后检查引用文献并进行一些清理。我在我在 A97 中使用的一个系统中使用了以下代码并制作了 A2000 和 A2002 MDB。这个想法是转换添加了一些我想以编程方式摆脱的引用,所以我不必担心它们。您可能希望将输出记录到一个与 MDB 同名的 .txt 文件中,并在执行过程中进行检查。

Function tt_FixReferences() As Boolean

Dim ref As Reference
Dim stMsg As String, intPosn As Integer, strRefPathName As String, blnCompile As Boolean


On Error GoTo tagError
For Each ref In Access.References
If ref.IsBroken Then
VBA.MsgBox "Ref" & ref.name & " is broken."
Else
' Debug.Print ref.Name & ", " & ref.FullPath
Select Case Access.SysCmd(acSysCmdAccessVer)
Case 9# ' Access 2000
If ref.name = "VBIDE" Then
strRefPathName = ref.FullPath
References.Remove ref
VBA.MsgBox strRefPathName & " removed."
blnCompile = True
End If
Case 10# ' Access 2002
If ref.name = "VBIDE" Or ref.name = "OWC10" Then
strRefPathName = ref.FullPath
References.Remove ref
VBA.MsgBox strRefPathName & " removed."
blnCompile = True
End If
End Select
End If
Next ref
tt_FixReferences = True
If blnCompile = True Then
Call Access.SysCmd(504, 16483)
MsgBox "Compiled."
End If


tagExit:
Exit Function

tagError:
If err = 48 Then ' ?????
If VBA.Len(VBA.Dir(ref.FullPath)) > 0 Then
References.AddFromGuid ref.Guid, ref.Major, ref.Minor
Resume Next
Else
stMsg = "Reference " & vbCrLf & "'" & ref.FullPath & "'" _
& vbCrLf & "couldn't be restored."
VBA.MsgBox stMsg, vbCritical + vbOKOnly, _
"Error restoring references."
tt_FixReferences = False
Resume tagExit
End If
Else
stMsg = "An unexpected error occurred." _
& vbCrLf & "Number: " & err.Number _
& vbCrLf & "Description: " & err.Description
VBA.MsgBox stMsg, vbCritical + vbOKOnly, _
"Error restoring references."
tt_FixReferences = False
Resume tagExit
End If
End Function

关于ms-access - 以编程方式将包含 Access 97 文件的文件夹更新为 Access 2003,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1331776/

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