English 中文(简体)
访问2010年字符串比较无效程序呼叫
原标题:Access 2010 String Comparison Invalid procedure call

We ve just upgraded from Access 2003 to Access 2010 and string comparisons are failing with an invalid procedure call error when default conditions are used. I’ve recreated two presumably related problems in a new Access 2007 format database containing only the default table, a query with the SQL below and a module containing only the code below, so I seriously doubt that this is a corruption issue. First the following sub fails on the If Then line with Run-time error 5: Invalid procedure call or argument

Option Compare Database
Option Explicit
Sub checkStrCmp()
     Dim str As String
     str = "s"
     If str = "s" Then
         MsgBox "works"
     End If
End Sub

如果我改变选项比较数据库与选项比较文本, 子系统会像预期的那样运作, 但这似乎是个坏主意, 我可能想要预设文本, 并在单个子系统内进行数字比较 。

在 SQL 内部的字符串比较函数中, 我也会收到“ 无效程序调用” 错误 。 替换函数需要所谓的可选比较参数 。

Select replace("foo-bar-baz", "-", "|", 1,-1);

生成“无效程序呼叫”错误

设置参数与任何可用值(0-3)的比较,以便按预期工作:

SELECT replace("foo-bar-baz", "-", "|", 1,-1, 0);

“foobarbaz”生产厂

Has anyone else seen this? Is there a setting that needs to be tweaked? Any other ideas outside of “Database corruption” which is all I’ve been able to find via Google. TIA

政策为草率的代码块 我无法为我的生命 让他们工作的权利。

UPATE: I should have mention that I m running XP Pro sp3, i m 正在运行 XP Pro sp3, < strong> UPATE: I should been mented that I m running XP Pro sp3.

问题似乎仅限于我在我的盒子上创建的数据库。 当我打开我从我们网络上的其他工作站上创建的测试数据库时,我看到了这个问题,但在创建上面描述的关于这些工作站的新数据库时却无法重新创建它。 我在其他两个工作站上创建的数据库(同样的OS和MS Office版本已安装)在打开我的机器时也是正确的。 当我从我的机器上插入了这些 DB 中的新模块时,我也无法重新创建这个问题。

简言之,问题似乎只存在于我机器上创建的数据库上(在旧的2003年格式数据库中,我在机器上转换为2007年格式 ) 。 我最好的猜测是,我的安装系统被冲洗了,但我想先了解一下如何和为什么我才使用信息技术,然后请求重新安装办公室。 我还想排除与我盒子上其他软件的冲突。

最佳回答

您的代码模块并不都需要共享相同的 optioncompare 设置。 因此您可以将那些应该使用文本比较的程序放在一个模块中, 该模块将 optioncompare Text 放在其声明部分中。

然而,我无法理解您的语句, “I may want to propform text 以及单一个子节中的数值比较。 ” 根据访问帮助专题, option比较语句 是“在模块一级使用 来声明字符串数据比较 时使用的默认比较方法 ” 。 换句话说, option比较 对数字值的比较没有任何影响。

< 坚固 > 编辑 < / 坚固 > : 由于问题仅限于只为一台机器创建的数据库文件 < code> option 比较数据库 , 我建议您检查该机器的存取“ 新的数据库排序顺序” 设置。 如果它被设置为其它东西, 则更改为以“ 常规” 开头的选择 。 然后创建一个新的数据库, 并查看您是否有问题 。

之所以提出这项建议,是因为 < code> Oppible compare Contraction数据库 告诉 Access 使用数据库代码设置进行排序。 而“ 新数据库排序顺序” 可以将代码设置为从未给我带来过如此麻烦的代码。 然而, 我对代码细节的理解很浅; 我从来不改变它, 不知道其他设置的后果是什么 。

问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签