运行时错误“3001”:在 Access VBA 中创建表时参数无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22008829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:07:21  来源:igfitidea点击:

Run-time error '3001': Invalid Argument when creating a table in Access VBA

vbams-accessaccess-vbams-access-2010

提问by Sinister Beard

When creating a table in Access VBA using the following code:

使用以下代码在 Access VBA 中创建表时:

Set tbl = dbs.CreateTableDef("" & strTableName & "")

I get the following error: Run-time error '3001': Invalid Argument. What causes this?

我收到以下错误:Run-time error '3001': Invalid Argument。这是什么原因造成的?

采纳答案by Sinister Beard

The name of the table you're trying to create (in the above example expressed as strTableName) is not valid - it's probably either null or too long.

您尝试创建的表的名称(在上面的示例中表示为strTableName)无效 - 它可能为空或太长。

The names of Access 2010 tables can be no longer than 64 characters. If strTableName is not null and has fewer than 64 characters, the above code will work perfectly.

Access 2010 表的名称不能超过 64 个字符。如果 strTableName 不为 null 且少于 64 个字符,则上述代码将完美运行。