需要有关日期字段验证的帮助 [英] Need help on Date field Validation

查看:86
本文介绍了需要有关日期字段验证的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用Access表单/子表单来设计数据库接口,一个字段是日期类型字段,但是我需要如果用户输入的未来日期比系统当前日期晚,我希望它弹出一条错误消息来提醒用户重新输入正确的日期,我不知道该怎么做。是否需要编写VBA代码或修改验证规则以及如何执行此操作,


谢谢

Currently I use Access form/subform to design a database interface, one field is date type field, but I need if the user inputs the future date like later than system currently date, I want it pop up an error message to remind the user to re-entry the correct date, I don?t know how to do it. Does it need write VBA code or modify the validation rule and how to do that,

Thank you

推荐答案

您可以在表格的设计视图中执行此操作

< = date()


<验证规则属性中的b。如果你走这条路线,请确保在验证文本属性中输入有意义的解释。


要在表单级别执行此操作,您需要以下代码:
You can do this in Design View for the table by using this

<=date()

in the Validation Rule Property. If you go this route, be sure and enter a meaningful explanation in the Validation Text Property.

To do this at the form level, you''ll need this code:
展开 | 选择 | 换行 | 行号



目前我使用Access表单/子表单来设计数据库接口,一个字段是日期类型字段,但是如果用户输入未来日期,我需要系统当前日期,我希望它弹出一条错误信息提醒用户重新输入正确的日期,我不知道该怎么做。是否需要编写VBA代码或修改验证规则以及如何执行此操作,


谢谢
Currently I use Access form/subform to design a database interface, one field is date type field, but I need if the user inputs the future date like later than system currently date, I want it pop up an error message to remind the user to re-entry the correct date, I don?t know how to do it. Does it need write VBA code or modify the validation rule and how to do that,

Thank you



您需要一些VBA代码。打开包含日期的文本框的属性,然后转到onExit事件。您将被带到VBA代码,并且会有一个''Private Sub''等着您。


键入以下代码:

You do need some VBA code. Open up the properties for the text box that has the date in it and go to the onExit event. You will be taken to the VBA code and there will be a ''Private Sub'' waiting for you.

Type in the following code:

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


感谢大家的回复,我觉得很幸运,我找到了这个有用的论坛。
thanks everybody''s reply, I feel so lucky I found this useful forum.


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

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