构建表达式 [英] Building an expression

查看:66
本文介绍了构建表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在为我的朋友建立一个客户数据库,我的朋友有晒黑业务。


在我的输入客户信息中如果在另一个字段中加上16年的日期值在今天的日期之前(否)或之后(是),我希望我的文本框返回YES或NO值。

目标是快速显示客户是否年龄小于16岁,并提示输入信息的任何人打印我已经创建的报告,该报告是必须由客户签署的豁免。

我知道这似乎很容易,但是我遇到了日期加上16部分的麻烦......

有谁可以帮我这个?


在此先感谢,

Tammy

Hello,
I am building a customer database for my friend who has a tanning business.

In my "Enter Customer Info" form I want my text box to return a YES or NO value if the date value entered in another field plus 16 years is before (NO) or after (YES) today''s date.
The object is to quickly show if a customer is younger than 16 years old and prompt whomever is entering the information to print a report I''ve created that is a waiver that must be signed by the customer.
I know it seems easy, but I''m having trouble with the date plus 16 part...
Can anyone help me with this?

Thanks in advance,
Tammy

推荐答案


您好,

我正在为我的朋友建立一个客户数据库,我的朋友有晒黑业务。


在我的输入客户信息中如果在另一个字段中加上16年的日期值在今天的日期之前(否)或之后(是),我希望我的文本框返回YES或NO值。

目标是快速显示客户是否年龄小于16岁,并提示输入信息的任何人打印我已经创建的报告,该报告是必须由客户签署的豁免。

我知道这似乎很容易,但是我遇到了日期加上16部分的麻烦......

有谁可以帮我这个?


在此先感谢,

Tammy
Hello,
I am building a customer database for my friend who has a tanning business.

In my "Enter Customer Info" form I want my text box to return a YES or NO value if the date value entered in another field plus 16 years is before (NO) or after (YES) today''s date.
The object is to quickly show if a customer is younger than 16 years old and prompt whomever is entering the information to print a report I''ve created that is a waiver that must be signed by the customer.
I know it seems easy, but I''m having trouble with the date plus 16 part...
Can anyone help me with this?

Thanks in advance,
Tammy



试试这个:


iif(DateDiff(" y",Birthdate,Date)< 16," YES"," NO")

Try this:

iif(DateDiff("y", Birthdate, Date) < 16, "YES", "NO")


实际上,应该是


iif(DateDiff(" y yyy ",Birthdate,Date)< 16," YES",NO)

>
间隔的单个 y 代表一年中的某一天。不是几年。


此代码的问题在于它不会返回准确的年龄!如果它在2007年的任何一天运行,并且出生日期是1991年的任何一天,它将产生16岁,因此返回否。但是,如果这个人还没有在2007年过生日,那么他们还不是16岁,它应该返回是。


这将返回实际年龄和产量适当的是或否:

Actually, that should be

iif(DateDiff("yyyy", Birthdate, Date) < 16, "YES", "NO")

The single y for interval stands for "day of year" not years.

The problem with this code is that it won''t return an accurate age! If it''s run on any day in 2007, and the Birthdate is any day in 1991, it will yield an age of 16 and thus return "No." But if the person hasn''t yet had a birthday in 2007, they''re not yet 16, and it should return "Yes."

This will return the actual age and yield the appropriate Yes or No:

展开 | 选择 | Wrap | 行号


感谢您的帮助。

我输入了表达式并且它正在返回#Name?在那个领域。

不确定出了什么问题...

Tammy
Thanks for the help.
I entered the expression and it''s returning #Name? in that field.
Not sure what is wrong...
Tammy


这篇关于构建表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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