在字段中排序或搜索条件时,数据类型不匹配 [英] Datatype mismatch when ordering or searching criteria in field

查看:58
本文介绍了在字段中排序或搜索条件时,数据类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Access 2007中尝试从名为ProjectNumber的文本字段中抓取2个字符。在确定前面要添加的2位数字以使其成为一年后,我需要这样做。我在下面的代码中已经完成了为 intPN 创建值。然后我需要将该值变为一个数字,以便我可以将它与一系列年份(1983-1987)进行比较。下面的代码按预期返回4个字符的年份。但是每当我尝试根据该字段订购或使用critera(where)时,我的条件表达式错误都会出现数据类型不匹配。我已经玩了这个代码2天了,如果数据类型不匹配错误弹出太多次,我准备去邮政了。所以任何帮助都会非常感激。这可能是非常简单的东西,我太厚了,无法看到它。谢谢。

I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done that in the code below to create a value for "intPN". I then need that value to become a number so that I can compare it to a range of years (1983-1987). The code below returns the 4 character year as intended. But I get a Datatype mismatch in criteria expression error whenever I try to order or use a critera (where) based on that field. I have been playing with this code for 2 days and am ready to go postal if the Datatype mismatch error pops up too many more times. So any help would really be appreciated. It is probably something really simple and I am too thick to see it. Thanks.

展开 | 选择 | Wrap | 行号

推荐答案

您是否尝试将数字与日期进行比较?如果没有看到结果的使用位置,我无法分辨。
Are you trying to compare numbers to dates? I can''t tell without seeing where the result is being used.


实际上我正在与一个数字进行比较。所以我可以这样说:

Actually I am comparing to a number. So that I could say this:

展开 | 选择 | Wrap | 行号


我能够创建错误的唯一方法这是当mid调用返回一个字母时。
The only way I have been able to create an error with this is when the call to mid returns a letter.


这篇关于在字段中排序或搜索条件时,数据类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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