访问 2013,在表单的加载文本期间出现错误 2128



我正在使用这里的代码。进行了一些小的修改。这在 Access 2016 中运行良好,但在导入 Access 2013 时会导致错误,该 Access 2013 将在 中使用。理想情况下,数据库需要与 2010 和 2013 一起使用。

我创建了一个具有 Access 2013(32 位)的 VM。我已经运行了有和没有修改的分解和撰写代码,并得到同样的错误。我还将文件类型从 mdb 更改为 accdb,因为这被认为是 Access 2013 失败的原因。

我尝试将 2016 版本保存到 2003 mdb。为此运行导入/导出,但它根本不起作用。然后在 Access 2013 中打开 mdb 并将其另存为 accdb,并返回相同的 2128 错误。

这是导出/分解代码的当前版本。目的是删除 2016 年至 2013 年期间不兼容的线路。

Option Explicit
const acForm = 2
const acModule = 5
const acMacro = 4
const acReport = 3
Const acQuery = 1
Const acExportTable = 0
' BEGIN CODE
Dim fso, relDoc
Dim sExportpath
Dim sExpModules
dim sADPFilename
Set fso = CreateObject("Scripting.FileSystemObject")
Set relDoc = CreateObject("Microsoft.XMLDOM")

If (WScript.Arguments.Count = 0) then
MsgBox "Please supply an Access DB Name!", vbExclamation, "Error"
Wscript.Quit()
End if
sADPFilename = fso.GetAbsolutePathName(WScript.Arguments(0))
If (WScript.Arguments.Count > 1) then
sExpModules = WScript.Arguments(1)
If Ucase(sExpModules) = "ALL" then
sExpModules = ""
End If
Else 
sExpModules = ""
End If
sExportpath = ""
exportModulesTxt sADPFilename, UCase(sExpModules)
If (Err <> 0) and (Err.Description <> NULL) Then
MsgBox Err.Description, vbExclamation, "Error"
Err.Clear
End If
Function exportModulesTxt(sADPFilename, sExpModules)
Dim myComponent
Dim sModuleType
Dim sTempname
Dim sOutstring
dim myType, myName, myPath, sStubADPFilename
myType = fso.GetExtensionName(sADPFilename)
myName = fso.GetBaseName(sADPFilename)
myPath = fso.GetParentFolderName(sADPFilename)
sExportpath = myPath & "Source"
sStubADPFilename = sExportpath & myName & "_stub." & myType
WScript.Echo "copy stub to " & sStubADPFilename & "..."
On Error Resume Next
fso.CreateFolder(sExportpath)
On Error Goto 0
fso.CopyFile sADPFilename, sStubADPFilename
WScript.Echo "starting Access..."
Dim oApplication
Set oApplication = CreateObject("Access.Application")
WScript.Echo "opening " & sStubADPFilename & " ..."
If (Right(sStubADPFilename,4) = ".adp") Then
oApplication.OpenAccessProject sStubADPFilename
Else
oApplication.OpenCurrentDatabase sStubADPFilename
End If
oApplication.Visible = false
WScript.Echo "exporting..."
Dim myObj
For Each myObj In oApplication.CurrentProject.AllForms
If sExpModules = "" or instr(sExpModules, Ucase(myObj.fullname)) > 0 then
WScript.Echo "  " & myObj.fullname
oApplication.SaveAsText acForm, myObj.fullname, sExportpath & "" & myObj.fullname & ".form"
oApplication.DoCmd.Close acForm, myObj.fullname
End if
Next
'sanitize forms since they contain version stuff that could break on import
SanitizeTextFiles sExportpath, "form"
For Each myObj In oApplication.CurrentProject.AllModules
If sExpModules = "" or instr(sExpModules, Ucase(myObj.fullname)) > 0 then
WScript.Echo "  " & myObj.fullname
oApplication.SaveAsText acModule, myObj.fullname, sExportpath & "" & myObj.fullname & ".base"
End if
Next
For Each myObj In oApplication.CurrentProject.AllMacros
If sExpModules = "" or instr(sExpModules, Ucase(myObj.fullname)) > 0 then
WScript.Echo "  " & myObj.fullname
oApplication.SaveAsText acMacro, myObj.fullname, sExportpath & "" & myObj.fullname & ".mac"
End if
Next
For Each myObj In oApplication.CurrentProject.AllReports
If sExpModules = "" or instr(sExpModules, Ucase(myObj.fullname)) > 0 then
WScript.Echo "  " & myObj.fullname
oApplication.SaveAsText acReport, myObj.fullname, sExportpath & "" & myObj.fullname & ".report"
End if
Next
For Each myObj In oApplication.CurrentDb.QueryDefs
If sExpModules = "" or instr(sExpModules, Ucase(myObj.name)) > 0 then
Wscript.Echo "Exporting QUERY " & myObj.Name
oApplication.SaveAsText acQuery, myObj.Name, sExportpath & "" & myObj.Name & ".query.txt"
End if
Next
WScript.Echo "compacting and overwriting stub ..."
oApplication.CloseCurrentDatabase
'oApplication.CompactRepair sStubADPFilename, sStubADPFilename & "_"
oApplication.Quit
fso.DeleteFile sStubADPFilename
WScript.Echo "Deleted StubFile"
'fso.CopyFile sStubADPFilename & "_", sStubADPFilename
'fso.DeleteFile sStubADPFilename & "_"

End Function
Sub SanitizeTextFiles(sImportpath, Ext)
Dim fso, InFile, OutFile, FileName, txt, obj_name, folder
Dim objectname, objecttype
Dim oldFileAndPath
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(sImportpath)
oldFileAndPath = ""
for each FileName in folder.Files
if oldFileAndPath > "" then
fso.Deletefile oldFileAndPath
fso.MoveFile oldFileAndPath & ".san", oldFileAndPath
oldFileAndPath = ""
end if
objecttype = fso.GetExtensionName(FileName.Name)
objectname = fso.GetBaseName(FileName.Name)
if objecttype = "form" then 
oldFileAndPath = sImportpath & Filename.name
Set InFile = fso.OpenTextFile(sImportpath & Filename.name, 1, false, -1)
Set OutFile = fso.CreateTextFile(sImportpath & Filename.name & ".san", True, True)
Do Until InFile.AtEndOfStream
txt = InFile.ReadLine
If Left(txt, 10) = "Checksum =" Then
' Skip lines starting with Checksum
ElseIf InStr(txt, "NoSaveCTIWhenDisabled =1") Then
' Skip lines containning NoSaveCTIWhenDisabled
ElseIf InStr(txt, "Begin") > 0 Then
If _
InStr(txt, "PrtDevNames =") > 0 Or _
InStr(txt, "PrtDevNamesW =") > 0 Or _
InStr(txt, "PrtDevModeW =") > 0 Or _
InStr(txt, "PrtDevMode =") > 0 _
Then
' skip this block of code
Do Until InFile.AtEndOfStream
txt = InFile.ReadLine
If InStr(txt, "End") Then Exit Do
Loop
Else                       ' This line needs to be added
OutFile.WriteLine txt
End If                     ' This line needs to be added
Else
OutFile.WriteLine txt
End If
Loop
OutFile.Close
InFile.Close
else
oldFileandPath = ""
end if
next
if oldFileAndPath > "" then
fso.Deletefile oldFileAndPath
fso.MoveFile oldFileAndPath & ".san", oldFileAndPath
end if
End Sub

我收到的错误代码是 2128。以及包含以下内容的文本文件:

数据库在导入对象
"form1"时遇到错误。

第 1 行遇到错误。 此对象是使用较新版本的数据库创建的 比您当前正在运行的。

尝试删除行

Version =19
VersionRequired =19
Checksum =-1389803315

LoadFromText之前的文本文件。

理想情况下,数据库需要与 2010 和 2013 一起使用。

然后,您必须在最早的版本 Access 2010 中进行开发。没有其他方法。

所以我有一个解决方案。

对于源代码管理,请继续使用分解和撰写代码。由于开发环境是2016年。

若要将更新发送到生产环境,请在 Access 2010/2013 中执行以下操作: 对于部署,将数据库拆分为开发和生产的前端/后端。然后,为了将来的更新,将新的前端从 Dev 发送到 Prod,然后重新链接表。

最新更新