窗体打开时是否提供了WhereCondition? [英] Was WhereCondition provided when form opened?

查看:90
本文介绍了窗体打开时是否提供了WhereCondition?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定表单打开时是否提供了WhereCondition?我想要的是,如果我只是打开表单(没有WhereCondition提供)它将转到一个新记录,但如果表单被打开到特定记录(提供WhereCondition),那么它将转到该记录。通常情况下,我会在'OnLoad事件的形式中放置一个 DoCmd.GoToRecord Record:= acNew 来做第一个选项,但我认为这会取消任何转到指定记录的尝试提供了。这就是为什么我想测试是否提供了WhereCondition。


我提交问题后,一个想法让我感到震惊。我可以在Load事件上测试Filter属性,看看它是否为空,以便知道是否提供了WhereCondition。

解决方案

Hi Seth。你是对的,你可以测试表单'的Filter属性来查看Where子句是否存在,但要确定给定的过滤器是否处于活动状态,你需要测试表单'的FilterOn属性,如果设置为True,则当前应用过滤器,否则为False。可以将表单的'filter属性设置为某个值,但是当时不应用过滤器。


-Stewart


事实上。我(非常)最近发现,更改表单的 .RecordSource 属性实际上将 .FilterOn 设置为False,但保留了 .Filter 以前。


一般来说,它更直接。如果设置 .Filter ,则通常 .FilterOn 为True。话虽如此,无论如何,测试它可能是最明智的。


这是一个非常好的观点。感谢分享。现在我很高兴我发布了它以便我能够获得这种洞察力。


Is it possible to determine if the WhereCondition was provided when the form was opened? What I''m wanting is that if I just open the form (no WhereCondition provided) it would go to a new record, but if the form was opened to a specific record (a WhereCondition was provided) then it would go to that record. Normally, I would put a DoCmd.GoToRecord Record:=acNew in the form''s OnLoad event to do the first option, but I think that would cancel any attempt to go to a specified record if one was provided. This is why I want to test if a WhereCondition was provided.

Right after I submitted the question an idea struck me. I can test for the Filter property on the Load event to see if it is blank or not to know if the WhereCondition was provided.

解决方案

Hi Seth. You are right that you can test the form''s Filter property to see whether a Where clause exists, but to know for sure whether the given filter is active you need to test the form''s FilterOn property which will be set True if the filter is currently applied, False if not. It is possible to have a form''s filter property set to some value but for the filter not to be applied at the time.

-Stewart


Indeed. I (very) recently discovered that changing the .RecordSource property of a form actually sets .FilterOn to False but leaves the .Filter as it was previously.

Generally it''s more straightforward though. If .Filter is set then generally .FilterOn is True. Having said that, it''s probably most sensible to test for it anyway.


That is a very good point. Thanks for sharing. Now I''m glad that I did post it so that I could get this insight.


这篇关于窗体打开时是否提供了WhereCondition?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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