我想编写一个简单的功能,在Windows 7来调整在MS Access 64位版本的文本字段它失败,错误3420,对象无效或不再设置。为什么是这样?你不能改变的code表了在MS访问64位版本?
下面是code:
专用功能ResizeSingleTextField(sTableName作为字符串_
sFieldName作为字符串_
iLength作为整数)
ResizeSingleTextField = FALSE
昏暗sSQL作为字符串
sSQL =ALTER TABLE和放大器; sTableName和放大器; _
&放大器; ALTER COLUMN&放大器; sFieldName和放大器; _
&放大器; TEXT(&放大器; iLength&安培;)
CurrentDb.Execute(sSQL)
ResizeSingleTextField = TRUE
退出功能
端功能
公用Sub调用testIt()
昏暗的结果作为布尔
结果= ResizeSingleTextField(GregTest,myTextField的,12)
Debug.Print结果
结束小组
解决方案
这是在该版本的Access一个已知的bug。请参阅Microsoft知识库中相应的第2516493 。
在这里摘录:
问题此修补程序包修复 假设您尝试更改 表的使用数据定义语言(DDL)查询结构 而在64位版本的Microsoft的ALTER TABLE语句 Access 2010中使用ALTER TABLE语句包括ALTER COLUMN 参数。在这种情况下,您会收到以下错误信息: 对象无效或不再设置。当您尝试执行DDL查询 通过VBA code,您会收到以下错误信息:运行时 错误'3420':对象无效或不再设置
有一个修补程序随附在四月来解决这个问题。 Access 2010中运行Service Pack 1的出来2011年8月,和根据发行说明包括针对此问题的修复。
访问 - 对象无效或不能再设置当您尝试时错误 使用ALTER TABLE查询,更改字段类型或大小。
I am trying to write a simple function to resize a text field in MS Access 64 bit version under Windows 7. It fails with the error 3420, object invalid or no longer set. Why is this? Can't you alter a table in code anymore under MS Access 64bit version?
Here is the code:
Private Function ResizeSingleTextField(sTableName As String, _
sFieldName As String, _
iLength As Integer)
ResizeSingleTextField = False
Dim sSQL As String
sSQL = "ALTER TABLE " & sTableName & " " _
& "ALTER COLUMN " & sFieldName & " " _
& "TEXT (" & iLength & ")"
CurrentDb.Execute (sSQL)
ResizeSingleTextField = True
Exit Function
End Function
Public Sub TestIt()
Dim result As Boolean
result = ResizeSingleTextField("GregTest", "MyTextField", 12)
Debug.Print result
End Sub
解决方案
It's a known bug in that version of Access. See MS Knowledge Base Article 2516493.
Excerpted here:
Issue that this hotfix package fixes Assume that you try to change the structure of a table by using a Data Definition Language (DDL) query and the ALTER TABLE statement in the 64-bit version of Microsoft Access 2010. The ALTER TABLE statement includes an ALTER COLUMN parameter. In this situation, you receive the following error message: Object invalid or no longer set. When you try to execute the DDL query through VBA code, you receive the following error message: Run-time error '3420': Object invalid or no longer set.
There is a hotfix that came out in April to remedy the issue. Access 2010 Runtime Service Pack 1 came out in August 2011, and according to the release notes includes a fix for this issue.
Access - "Object invalid or no longer set" error occurs when you try to use an ALTER TABLE query to change a field type or size.
相关推荐
最新文章