搜索表单/查询日期 - 获取不匹配错误 [英] Search form/query with dates - getting mismatch errors

查看:52
本文介绍了搜索表单/查询日期 - 获取不匹配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在VBA并不擅长,但是除了几个问题之外,他们已经在互联网上发现了其他人的代码,这个问题我现在正在工作是我不能搜索约会。有人在这里提到#''的使用,但我不确定我目前的代码如何 - 我可能需要重新编写日期部分..?


目前我有:

Hello,
I''m not great at VBA but have hammered someone else''s code found on the internet into shape except for a couple of issues, the one I''m currently working on is that I can''t search for a date. Someone on here mentioned use of #''s but I''m not sure how with the code I currently have - could be I need to re-write the section for the date..?

Currently I have:

展开 | 选择 | Wrap | 行号

推荐答案

是的,只要您有日期,您从中提取数据的字段通常应将标准括在#中。标志


因此,在您发布的小代码块中,如果字段[DateCreated]在表级别作为日期字段格式化,那么您将替换单引号(" ''")和#得到类似的东西:
Yes, anytime you have a "Date" field that you are pulling data from you should normally enclose the criteria within the "#" signs

So in the small block of code you posted, if the field [DateCreated] is formated at the table level as a date field, then you would replace the single quotes ( " '' ") with the "#" to get something like:
展开 | 选择 | Wrap | 行号


这很好,谢谢,清除了初始问题。现在,这突出了一些不同的东西 - 当我搜索''08 / 04/1991''或'07 / 05/1991'时,我什么都没得到(尽管有那个日期的记录),但当我搜索时'13 / 08/1991''或'20 / 08/1991''我得到了点击......是否与前面的''0'有关?或者我的代码坏了吗? :P


感谢您的帮助:)
That''s great, thanks, cleared the initial issue. Now that''s highlighted something different - when I search for ''08/04/1991'' or ''07/05/1991'' I get nothing (despite there being a record with that date), but when I search ''13/08/1991'' or ''20/08/1991'' I get hits... Is it something to do with the preceding ''0''? Or is my code just that broken? :P

Thanks for the help :)


只要日期在#之内,就没有关系。如果您使用单引号或双引号,则在日期字段上搜索时会遇到问题。如果该字段碰巧是文本,则搜索非常简单并且条目00表示该字段。不等于0。等...


请在设计视图中返回到您的表格并仔细检查为该字段设置的数据类型。
It shouldn''t matter so long as the date is within the "#" If you use a single or double quote you will have issues searching on a date-field. If the field happens to be text, then the search is quite litteral and the entry "00" does not equal "0" etc...

Please go back in to your table in design view and double check what data type has been set for the field.


这篇关于搜索表单/查询日期 - 获取不匹配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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