使用VB6过滤Access中的日期字段 [英] filtering on a date field in Access using VB6

查看:156
本文介绍了使用VB6过滤Access中的日期字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在使用VB6(在windows7中运行)与Access数据库交谈时遇到问题,并希望有人

可以帮助我找到错误。


数据库包含一个DateIn类型字段日期 (短日期)

我正在将表读入一个名为rsDiv的记录集中


我试图只阅读本财政年度的记录[7月1日(姓名)]到[明年6月30日]。


我的代码如下.....

Hi all,

I am having trouble with VB6 (running in windows7) talking to an Access database, and was hoping someone
could help me locate the error.

the database contains a "DateIn" field of type "Date" (short Date)
I am reading the table into a recordset called "rsDiv"

I am trying to read only records for the financial year, between [1 Jul (name the year)] to [30 Jun] the next year.

my code is as follows.....

展开 | 选择 | Wrap | 行号

推荐答案




最近我遇到了类似的过滤不一致的问题记录集。


但是,我几乎只在VBA(Excel和Access)中工作le .Net或独立的exe程序,并且总是使用ADO对象,所以这可能使我的帖子无效?


在代码中你需要将日期格式化为''America''即。 MM / DD / YY。这在创建记录集时总是工作正常,但不会过滤它,因此结果不一致。


我的解决方案是使用''通用''日期格式yyyy / mm / dd。


因此我建议你试试这个
Hi

Just recently I have a similar problem with inconsistent filtering of a recordset.

However, I work almost exclusively in VBA (Excel and Access) and a little in .Net or stand alone exe programms, and always use ADO objects, so this may invalidate my post?

In code you need to format the date as ''America'' ie. mm/dd/yy. This has always worked fine when creating record sets, but not filtering it would seem, hence the inconsistent results.

My solution was to use the ''universal'' date format yyyy/mm/dd.

Therefore I would suggest you try this
展开 | 选择 | Wrap | 行号


在Access VBA中,协助从设置过滤器,您还必须打开过滤器。我不知道VB6是否也是如此。
In Access VBA, asside from setting the filter, you also have to turn the filter on. I don''t know if that is also the case for VB6.





我相信ADO(和DAO?)记录集不要没有FilterOn属性(这是Form属性);删除你刚刚使用的过滤.Filter =""


我也认为ADO对象在VB6和VBA中是相同的,但是我还没有使用VB6 10年。


MTB
Hi

I believe that ADO (and DAO?) recordsets don''t have a FilterOn property (this is Form property); to remove the filtering you just use .Filter = ""

I also think that ADO objects are the same in VB6 and VBA, but I haven''t used VB6 for about 10 years.


MTB


这篇关于使用VB6过滤Access中的日期字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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