如何验证四分之一小时的增量? [英] how to validate quarter-hour increments??
问题描述
我希望以季度时间为增量验证工作时间,例如
..25,.5,.75,1.0等等。
I知道我可以使用modulo语句进行评估,但我不能在表单字段验证中找到如何使用它的解释。
我相当肯定它会如果结果= Me.FormField
mod .25是一个偶数整数(可被.25整除)
我想代码将是[Me.formfield] %.25 ???
我在Access帮助中找不到任何东西。
谢谢你,汤姆
I am looking to validate time worked in quarter-hour increments, e.g.
..25, .5, .75, 1.0, etc. etc.
I know I can use a modulo statement for the evaluation but I could not
find an explanation of how to use this in a form field validation.
I am fairly certain it would be something like If result=Me.FormField
mod .25 is an even integer (evenly divisible by .25)
I imagine the code would be [Me.formfield]%.25???
I cannot find anything in Access help, either.
Thank you, Tom
推荐答案
tlyczko写道:
tlyczko wrote:
我希望以季度时间为增量验证工作时间,例如
。25,.5, .75,1.0等。
我知道我可以使用modulo语句进行评估,但我无法在表单字段验证中找到如何使用它的说明。
我相当肯定它会像If result = Me.FormField
mod .25是一个偶数整数(可被.25整除)
我想代码将是[Me.formfield]%。25 ???
我找不到任何东西在Access帮助中,或者。
I am looking to validate time worked in quarter-hour increments, e.g.
.25, .5, .75, 1.0, etc. etc.
I know I can use a modulo statement for the evaluation but I could not
find an explanation of how to use this in a form field validation.
I am fairly certain it would be something like If result=Me.FormField
mod .25 is an even integer (evenly divisible by .25)
I imagine the code would be [Me.formfield]%.25???
I cannot find anything in Access help, either.
要使Mod工作,你必须有整数。通过除以最小步长(或乘以
反转,将其读取更容易一些),将值提升到整数
平面。
>
然而,当我尝试输入一个表达式时,我发现我会稍稍偏向一个角度
:
[field] * 4 = Int(字段* 4)
会告诉您字段是否为 (这不是你的真实姓名:-))
.25的完全倍数
-
Bas Cost Budde,荷兰
http://www.heuveltop.nl/ BasCB / msac_index.html
For Mod to work you must have integers. Lift the values to the integer
plane by dividing by the smallest step size (or multiplying by its
inverse which reads a little easier).
However, when trying to type an expression I found I would take an angle
slightly to the side:
[field]*4 = Int(field*4)
will tell you whether "field" (this is not your real field name :-) ) is
an exact multiple of .25
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
tlyczko写道:
tlyczko wrote:
我希望验证每小时工作的时间增量,例如
.25,.5,.75,1.0等等。
我知道我可以使用模数语句进行评估,但我无法找到如何解释在表单字段验证中使用它。
我相当肯定它会像是if result = Me.FormField
mod .25是一个偶数整数(可被.25整除)
我想代码是[Me.formfield]%。25 ???
我在Access帮助中也找不到任何东西。
谢谢你,Tom
I am looking to validate time worked in quarter-hour increments, e.g.
.25, .5, .75, 1.0, etc. etc.
I know I can use a modulo statement for the evaluation but I could not
find an explanation of how to use this in a form field validation.
I am fairly certain it would be something like If result=Me.FormField
mod .25 is an even integer (evenly divisible by .25)
I imagine the code would be [Me.formfield]%.25???
I cannot find anything in Access help, either.
Thank you, Tom
>
通常我建议验证工作时间乘以4;
但是我认为最好为浮点错误添加一点自我保证金
。
我想要.24999和.25001都有效,但不是.26或.24。
..24999 * 4 = 0.99996
..25001 * 4 = 1.00004
因此Int(Nz(txtEmployeeHours.Value)* 4 + 0.5)应该提供最近的
整数用于比较。 />
Abs(Int(Nz(txtEmployeeHours.Value)* 4 + 0.5) -
Nz(txtEmployeeHours.Value)* 4)< 0.01
应该非常安全。
例如:
..24 Abs(Int(.96 +) .5) - .96)=。04无效
.249 Abs(Int(.996 + .5) - .996)= .004有效
.. 25 Abs(Int(1 + .5) - 1)= 0有效
.251 Abs(Int(1.004 + 0.5) - 1.004)= .004有效
..26 Abs(Int(1.04 + 0.5) - 1.04)= .04无效
如果您只想自动舍入到最接近的.25小时:
Int(Nz(txtEmployeeHours.Value))* 4 + 0.5)/ 4#
可能还有其他解决方案使用Mod功能。
您可以将0.01调整为更小的值。
James A. Fortune
Normally I''d suggest to validate the time worked multiplied by four;
but I think it''s better to add a little bit of self-defensive margin
for floating point error.
I''d like both .24999 and .25001 to be valid, but not .26 or .24.
..24999 * 4 = 0.99996
..25001 * 4 = 1.00004
So Int(Nz(txtEmployeeHours.Value) * 4 + 0.5) should provide the nearest
integer to be used for the comparison.
Abs(Int(Nz(txtEmployeeHours.Value) * 4 + 0.5) -
Nz(txtEmployeeHours.Value) * 4) < 0.01
should be pretty safe.
Examples:
..24 Abs(Int(.96 + .5) - .96) = .04 invalid
..249 Abs(Int(.996 + .5) - .996) = .004 valid
..25 Abs(Int(1 + .5) - 1) = 0 valid
..251 Abs(Int(1.004 + 0.5) - 1.004) = .004 valid
..26 Abs(Int(1.04 + 0.5) - 1.04) = .04 invalid
If you just want to round to the nearest .25 hour automatically:
Int(Nz(txtEmployeeHours.Value)) * 4 + 0.5) / 4#
There may also be other solutions that use the Mod function instead.
You can adjust 0.01 to smaller values.
James A. Fortune
您好,
我想你可以将你的输入乘以100然后再做
Mod(条目,25),如果这是0 ,那么它是.25的倍数 - 如果
没有,你就有错误。
当然,我可能是错的......
J imA
Hi,
I''m thinking that you could just multiply your entry by 100 and then do
the Mod(entry, 25) and if this is 0, then it is a multiple of .25 - if
not, you have an error.
Of course, I could be wrong...
JimA
这篇关于如何验证四分之一小时的增量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!