访问 2013,LoadfromText 期间的错误 2128 表单
Posted
技术标签:
【中文标题】访问 2013,LoadfromText 期间的错误 2128 表单【英文标题】:Access 2013, error 2128 during LoadfromText for forms 【发布时间】:2019-07-10 22:38:30 【问题描述】:我正在使用来自here 的代码。有一些小的修改。这在 Access 2016 中运行良好,但在使用 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 行遇到错误。 此对象是使用较新版本的数据库创建的 比你目前正在运行的。
【问题讨论】:
【参考方案1】:尝试删除行
Version =19
VersionRequired =19
Checksum =-1389803315
来自LoadFromText
之前的文本文件。
【讨论】:
【参考方案2】:理想情况下,该数据库需要与 2010 年和 2013 年一起使用。
那么您将不得不在 Access 2010 中进行开发,这是最早的版本。没有其他方法。
【讨论】:
关于 2010 年在哪里获得访问权限的任何建议? eBay 有几个优惠。【参考方案3】:所以我有一个解决方案。
对于源代码控制,请继续使用分解和组合代码。由于开发环境是2016年。
要将更新发送到生产环境,请在 access 2010/2013 中执行以下操作:对于部署,将数据库拆分为 Dev 和 Prod 的前端/后端。然后为将来的更新将新的前端从 Dev 发送到 Prod。其次,重新链接表格。
【讨论】:
以上是关于访问 2013,LoadfromText 期间的错误 2128 表单的主要内容,如果未能解决你的问题,请参考以下文章
Firefox 上的 Google Analytics JS 代码中的“返回语句后代码无法访问”错误 - 这是我的错吗?