存储没有基础表的复选框值 [英] Storing checkbox value without underlying table

查看:44
本文介绍了存储没有基础表的复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access 2003数据库,其表格实际上是一个小型交换机,包含各种报告的选项按钮等。在一年的大约1-2个月中,这个迷你交换机一直在使用。今年剩下的时间里,根本不需要它。我想在迷你交换机上添加一个复选框,以便用户可以选择它来启动迷你交换机(除主交换机外),这样它就可以在相关的月份内一直保持打开状态。然后可以取消选中该复选框,以便在剩下的时间内保持不变。


如果选中该复选框,我已经弄清楚如何使表单加载但是我确实难以接受如何存储复选框的值。由于表单仅包含菜单选项,因此没有用于存储任何字段值的基础表。我知道我可以创建一个表并在其中存储yes / no值,但访问该字段的默认值属性并将信息存储在那里似乎更简单。那可能吗?有没有办法对表单进行编码,以便在表单关闭时捕获复选框的值,然后将值存储为复选框的默认值,以便下次表单打开时,它会记住该值吗?

解决方案

我不相信有任何方法可以对表单属性进行非易失性更改,而无需在设计视图中打开表单进行更改然后保存。你可以在vba中做到这一点,但这似乎是一种非常尴尬的做事方式。我会按照你的想法创建一个包含该值的表。当表单关闭时,运行一个查询以根据表单中的内容在关闭时更新该值,然后您可以在表单启动时将其更改为表中的内容。如果表单应该可见的日期很难且很快(在该范围之外不需要访问),您只需将逻辑编码到表单的'open事件中,告诉它您是否在相关的日期范围内显示否则不要。




我怀疑,虽然我没有特别检查出来,如果你编码点击事件检查自己的值,然后使用您自己制作的代码(显示/隐藏或真实/假等)设置表单的标签属性,然后打开事件可以在下次分析Tag属性。


无需以编程方式进入设计模式,但在关闭表单时可能需要强制保存。


Jim


如果您愿意,也可以创建自定义属性。

http://allenbrowne.com/ser-09。 HTML

I have an Access 2003 database with a form that is actually a mini-switchboard containing option buttons for various reports, etc. During about 1-2 months of the year, this mini-switchboard is used all the time. The rest of the year, it is not needed at all. I would like to add a checkbox to the mini-switchboard so users can select it to make the mini-switchboard load at startup (in addition to the main switchboard) so it could stay open all the time during the relevant month(s). The checkbox could then be deselected to stay out of the way the rest of the time.

I have figured out how to make the form load if the checkbox is selected but am stumped by exactly how to store the checkbox''s value. Since the form contains only menu options, there is no underlying table to store any field values. I know I could create a table and store just the yes/no value in it but it seems simpler to access the field''s default value property and store the information in there. Is that possible? Is there a way to code the form so that the value of the checkbox is captured when the form closes, then the value is stored as the checkbox''s default value so the next time the form opens, it remembers that value?

解决方案

I don''t believe there is any way to make non-volatile changes to the forms properties without opening the form in design view making the change and then saving. You could do that in vba but that seems a very awkward way of doing things. I would go with your idea and create a table that has that single value in it. When the form closes run a query to update that value based on what is in the form when it closes, then you can change it to what''s in the table when the form starts up. If the dates for when the form should be visible are hard and fast (no access is needed outside that range) you can merely code logic into the form''s open event that that tells it if you are in the relevant date range show the form else don''t.


Hi,
I suspect, although I aint''nt checked it out specifically, that if you code the on-click event to check its own value and then set the form''s Tag property with a code of your own making ("Show"/"Hide" or "True"/"False" etc) then the on-open event could analyse the Tag property next time.

No need to programatically go into design mode, but you may need to force a save when you close the form.

Jim


You could also create a Custom Property if you wanted to.
http://allenbrowne.com/ser-09.html


这篇关于存储没有基础表的复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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