基于日期重复 [英] Duplicates based on date

查看:45
本文介绍了基于日期重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表格来安排约会。我们安排了我们称之为第一个上午的事情。和第一下午每天预约。我将这两个选项显示为表单上的复选框。它们是基础表中的是/否字段。我希望当用户检查其中任何一个时,数据库要查看我在日期字段中输入的日期,并确保当天已经检查了另一个上午或下午。因为我们每天只能有一个。这样的事情可能吗?谢谢

I have a form to schedule appointments. We schedule what we call a "first am" and a "first pm" appointment for each day. I have these two options displayed as check boxes on my form. They are yes/no fields in the underlying table. I would like when the user checks either one of them, for the database to look at the date that has been entered in my date field and make sure that there isnt another first am or pm already checked for that day. As we can only have one of each per day. Is something like this possible? thanks

推荐答案

完全有可能。检查将包含一个DCount(),您在其中搜索表中所有日期等于所选日期且上午或下午为真的记录。如果它等于0以上则已经安排好了。


有几种方法可以实现这一点。您可以检查何时选中第一个AM框,如果该点已经填满,则自动取消选中它。您还可以使用日期字段'的After_Update事件来运行DCount(),并在DCount()返回任何内容时禁用该复选框。这样可以让您知道选择日期后是否立即拍摄该地点。如果你想做后面的选项,那么我会使用一个If / Then语句来确保更新日期字段是不是要删除日期,因为尝试运行DCount()而没有填充日期会导致一个错误。像
It is totally possible. The check would consist of a DCount() where you search your table for all records where the date equals the selected date and first am or pm is true. If it equals more than 0 then it is already scheduled.

There are a couple of ways to implement this. You could check when the first AM box is checked and automatically uncheck it if that spot is already filled. You could also use the date field''s After_Update event to run the DCount() and disable the checkbox if the DCount() returns anything. This would make it so that you would know if the spot is taken as soon as you select the date. If you want to do the later option, then I would use an If/Then statement to make sure the update to the date field wasn''t to remove the date as trying to run the DCount() without the date being populated would cause an error. Something like
展开 | 选择 | Wrap | 行号


我使用以下内容并返回以下消息运行时错误''3464' ':标准表达式中的数据类型不匹配。日期字段设置为表格中的日期/时间字段。

I am using the following and it is returning the following message "run time error ''3464'': data type mismatch in criteria expression". the date field is set as a date/time field in the table.

展开 | 选择 | Wrap < span class =codeDivider> | 行号


我相信你需要将您的标准更改为
I believe that you would need to change your criteria to
展开 | 选择 | Wrap | 行号


这篇关于基于日期重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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