更改表在 MS Access 64 位下不起作用.为什么? [英] Alter Table doesn't work under MS Access 64 bit. Why?

查看:29
本文介绍了更改表在 MS Access 64 位下不起作用.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的函数来在 Windows 7 下的 MS Access 64 位版本中调整文本字段的大小.它因错误 3420、对象无效或不再设置而失败.为什么是这样?在 MS Access 64 位版本下,您不能再更改代码中的表格了吗?

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?

代码如下:

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

推荐答案

这是该版本 Access 中的一个已知错误.请参阅 MS 知识库文章 2516493.

It's a known bug in that version of Access. See MS Knowledge Base Article 2516493.

此处摘录:

此修补程序包修复的问题
假设您尝试更改使用数据定义语言 (DDL) 查询的表结构和 64 位版本的 Microsoft 中的 ALTER TABLE 语句Access 2010. ALTER TABLE 语句包括一个 ALTER COLUMN范围.在这种情况下,您会收到以下错误消息:对象无效或不再设置.当您尝试执行 DDL 查询时通过 VBA 代码,您会收到以下错误消息:运行时错误3420":对象无效或不再设置.

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.

有一个 hotfix4 月推出以解决该问题.Access 2010 Runtime Service Pack 1 于 2011 年 8 月发布,并且根据发行说明包含针对此问题的修复.

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.

访问 - 当您尝试访问时出现对象无效或不再设置"错误使用 ALTER TABLE 查询更改字段类型或大小.

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.

这篇关于更改表在 MS Access 64 位下不起作用.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆