anyway, if you want to keep future values from having decimal places,
you can do this on the form control BeforeUpdate event:
'~~~~~~~~~~~
if isNull(me.Activecontrol) then exit sub
if ABS(me.Activecontrol - Int(me.Activecontrol)) > 0.01 then
msgbox "You cannot enter decimal places",,"Correct Entry"
CANCEL = true
endif
'~~~~~~~~~~~
WHERE
0.01 is your tolerance -- any difference under that will be corrected
automatically
and then, to correct any decimal places beyond the tolerance, on the
control AfterUpdate event:
'~~~~~~~~~~~
if isNull(me.Activecontrol) then exit sub
if me.Activecontrol <> Int(me.Activecontrol) then
me.Activecontrol = Int(me.Activecontrol)
endif
'~~~~~~~~~~~
Int is a function to convert a value to its whole number part
you can use Fix instead of Int
from Help:
"The difference between Int and Fix is that if number is negative, Int
returns the first negative integer less than or equal to number, whereas
Fix returns the first negative integer greater than or equal to number.
For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8."
Warm Regards,
Crystal
remote programming and training
Access Basics
8-part free tutorial that covers essentials in Accesshttp://
www.AccessMVP.com/strive4peace
*
have an awesome day
*
(e-mail address removed) wrote:
Thanks, Crystal!
What if the data type has to be Double, Fixed, 4 Decimals? Ultimately,
I'm trying to assure that 0 and less than 0 are never entered. If I
change the data type to Integer or Long Integer then I won't be able
to store 2.25 (i.e.). Furthermore, an existing 2.25 will be changed to
2 - YIKES!
Hi John,
Make the DATA TYPE in the table design either Integer (<= 32K) or Long
Integer
"The form control for UnitCount is Fixed with 0 decimal points. "
this refers to FORMAT -- how something is displayed, not how it is stored...
Warm Regards,
Crystal
remote programming and training
Access Basics
8-part free tutorial that covers essentials in Accesshttp://
www.AccessMVP.com/strive4peace
*
have an awesome day
*
(e-mail address removed) wrote:
If Me!UnitCount <= 0 Then
Beep
If MsgBox("Unit Count is ZERO or less than ZERO!" & vbCrLf & _
"Unit Count must be greater than ZERO." & vbCrLf & _
"Click OK to set to NULL.", vbOKOnly + _
vbQuestion) = vbOK Then
[UnitCount] = Null
Cancel = True
End If
End If
The form control for UnitCount is Fixed with 0 decimal points. The
underlying table field is also formatted as such.
UnitCount may be Null but can never be 0 or less than 0. If 0.1 is
entered into the form control then of course, 0 will display and be
allowed.
What can I do to disallow decimals?
Thanks in advance!- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -