如何比较Access窗体中的两个日期字段? [英] How to compare two date fields in an Access Form?

查看:160
本文介绍了如何比较Access窗体中的两个日期字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在访问表单上比较两个不同的日期字段时遇到了困难。防爆。如果日期2小于日期1 ...我希望系统显示一个消息...说日期2必须大于日期一。

解决方案

你好stress999,


假设您有一些名称与下面类似的控件,那么在AfterUpdate事件中的每个Date字段后面都会有VBA。您的代码看起来与此类似:

展开 | 选择 | Wrap | 行号


感谢Twinnyfo - 这是我正在寻找的语法。很棒的东西!


你好Twinnyfo,

我试图插入上面的代码...出于某种原因它出错了。为了测试确切的代码,我创建了2个文本框,其中包含您在代码中使用的字段名称。

代码是从General中插入的。选项。

I am having difficulty comparing two different date fields on my access form. Ex. If date two is less than date one... I want the system to display a msg... saying date two must be greater than date one.

解决方案

Hi stress999,

Assuming you have some controls named similarly as below, you would have VBA behind each of your Date fields in the AfterUpdate Event. Your code would look similar to this:

Expand|Select|Wrap|Line Numbers


Thanks Twinnyfo - this is syntax I was looking for. Great stuff!


Hi Twinnyfo,
I tried to insert the code above... for some reason it errors out. To test the exact code, I created 2 text boxes with the field names you used in the code.
The code was inserted from the "General" option.


这篇关于如何比较Access窗体中的两个日期字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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