DtPicker - 奇怪的行为 [英] DtPicker - weird behaviour

查看:95
本文介绍了DtPicker - 奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

短版:当VBA代码中的 .Enabled 发生变化时,DtPicker会变得很奇怪,寻找解决方案或解决方法。

Looooong版本

那些一直关注各种线程的人会知道我有一个相当大的Access 2003数据库(实际上已经拆分了)多个后端数据库和一个前端),用户通过在表单上输入标准进行搜索。


这些标准包括三个日期/时间字段。对于每个,我有一对日期/时间选择器控件,用户在其中选择值,以将搜索限制为日期/时间范围。最初我只是检查值并根据它们是否已从默认值更改来生成WHERE子句。然而,由于三个时间顺序信息之间的关系(真实世界,而不是数据库),这比我喜欢的要复杂得多。所以我在每对旁边都放了一个复选框,目的是要求用户打开?他们想要使用的每个标准。 (通常用户不会对这些标准感兴趣)。


这是我的问题。单击复选框并关闭日期/时间选择器的 .Enabled 属性时,它会丢失它的自定义格式(显示日期和月份到分钟)并切换回显示只是短暂的约会。更糟糕的是(很多更糟),再次启用时,它变成一个空白框,日期/时间输入字段出现在表单的左上角。打开或关闭 .Visible 属性似乎确实有效,但我宁愿让控件在视觉上被禁用而不是完全隐藏它。如果我这样做,我将不得不在那里添加其他东西以指示复选框的用途(因为与VB6不同,Access有助于将标签与控件一起隐藏。)


我不知道我们能为此做些什么,但想到我还是要问。


另一方面,是否有人对另一种视觉启用方式有一个很好的建议/当用户点击相应的复选框时,禁用日期/时间选择器控件?目前我已经在每个周围放置了一个红色边框,并将其更改为绿色以表示它已启用。看起来不太好。 :(我尝试打开/关闭 .Locked 属性,但它似乎没有任何效果。无法找到ForeColor或BackColor属性。尝试设置CalendarBackColor(我认为),但它只影响弹出日历。

解决方案

尝试设置.Visible属性(布尔值)。

对控件完全没有影响。



尝试设置.Visible属性(布尔值)。

这个应该对控件完全没有影响。



感谢NeoPa。


然而,我已经尝试过了。有两个问题,一个是小问题,一个是我认为是一个显示停止。

  • 当隐藏时,你有一个复选框坐在那里没有明显的原因。
    这是次要的麻烦,只是意味着我需要在表格上加上其他东西来表明这个特定的选项已经关闭。
  • Wh我再次看到它,它失去了自定义格式并回到丑陋的短日期格式。

    这当然是一个真正的问题,因为它是(A)Yank格式,和( B)意味着包括时间。
我已经注意到来自Access中的dtpicker的这种奇怪的行为。它似乎失去了一滴一滴的自定义格式。几乎我做的任何事情都会使它恢复到美国的短日期格式。 (至少我认为它就是这样 - 没有检查过一段时间。)



尝试设置。可见属性(布尔值)。

这应该 对控件没有任何影响



看起来有点无意义,你不是吗? ;)


Hi all.

Short version: DtPicker goes strange when .Enabled changed in VBA code, looking for solution or good workaround.

Looooong version:
Those of you who have been following various threads here will know that I have a fairly large Access 2003 database (actually split over multiple backend databases and a front-end), which users search by entering criteria on a form.

Among these criteria are three date/time fields. For each, I have a pair of date/time picker controls in which the user chooses a from and to value, to limit the search to a date/time range. Initially I was simply checking the values and generating WHERE clauses based on whether they had been changed from their default values. However, this is proving more complex than I like, due to relationships (real-world, not database) between the three pieces of chronological information. So I?ve placed a checkbox next to each pair, with the intention of requiring the user to ?turn on? each criterion they want to use. (Normally the user won?t be interested in these criteria).

Here?s my problem, though. When the checkbox is clicked and I turn off the .Enabled property of a date/time picker, it loses it?s custom format (which shows date and month down to the minute) and switched back to showing just the short date. Worse still (much worse), when enabled again, it turns into a blank box, and the date/time entry field appears at the top-left corner of the form. Turning .Visible property on or off does seem to work, but I would prefer to leave the control visually disabled rather than hide it completely. If I do that, I''ll have to put something else there to indicate what the checkbox is for (since unlike VB6, Access helpfully hides the label along with the control.)

I don?t know what we can do about this, but figured I?d ask anyway.

On the other hand, does anyone have a good suggestion on another way to visually enable/disable the date/time picker controls when the user hits the corresponding checkbox? For the moment I have placed a red border around each one, and change it to green to indicate it?s enabled. Doesn?t look so good. :( I tried turning the .Locked property on/off, but it doesn?t seem to have any effect at all. Can?t find a ForeColor or BackColor property. Tried setting the CalendarBackColor (I think) but it only affected the popup calendar.

解决方案

Try setting the .Visible property (Boolean).
This should have no effect on the control at all.


Try setting the .Visible property (Boolean).
This should have no effect on the control at all.

Thanks NeoPa.

However, I have tried that. There are two problems, one minor and one which I consider a show-stopper.

  • When hidden, you have a checkbox sitting there for no apparent reason.
    This is the minor nuisance, it just means I would need to put something else on the form to indicate that this particular option is turned off.
  • When I make it visible again, it loses the custom format and goes back to the ugly short date format.
    This is a real problem of course, since it is (A) in Yank format, and (B) meant to include the time.
I''ve noticed quite a bit of weird behaviour like this from the dtpicker in Access. It seems to lose the custom format "at the drop of a hat". Almost anything I do causes it to revert to the American short date format. (At least I think that''s what it was - haven''t checked for a while).


Try setting the .Visible property (Boolean).
This should have no effect on the control at all.

Seems a bit pointless then, wouldn''t you say? ;)


这篇关于DtPicker - 奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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