<= 0

J

jlute

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!
 
S

strive4peace

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 Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
J

jlute

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 :)
  *



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 -
 
S

strive4peace

Hi John,

"What can I do to disallow decimals?"

then I do not understand why you want to store the number so it can have
decimals places ...

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 Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*




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 :)
*



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 -
 
J

jlute

then I do not understand why you want to store the number so it can have
decimals places ...

Sorry. Maybe this is clearer:
The field can be Null or store values with decimal places but never 0
or less than 0.

Thanks for the tips!!!
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 :)
  *



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 -
 
K

KARL DEWEY

Then use validation --- >0

--
KARL DEWEY
Build a little - Test a little


then I do not understand why you want to store the number so it can have
decimals places ...

Sorry. Maybe this is clearer:
The field can be Null or store values with decimal places but never 0
or less than 0.

Thanks for the tips!!!
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 :)
*



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!
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 -
 
S

strive4peace

.... or less than 0.5 (since that would round to zero and you said you
didn't want 0.1)?

why this restriction? what kind of data is this?

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*




then I do not understand why you want to store the number so it can have
decimals places ...

Sorry. Maybe this is clearer:
The field can be Null or store values with decimal places but never 0
or less than 0.

Thanks for the tips!!!
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 :)
*



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 -
 
J

John W. Vinson

Sorry. Maybe this is clearer:
The field can be Null or store values with decimal places but never 0
or less than 0.

But you say in your first post:

The form control for UnitCount is Fixed with 0 decimal points. The
underlying table field is also formatted as such.

WITH decimal places? Or WITHOUT decimal places? Choose only one!
 
J

JohnLute

why this restriction? what kind of data is this?

It's a field for a whole number that represents just what its field name
implies - a unit count. It can be null but never a decimal, 0 or less than
zero. For example, 10/.5 gal. 10 being the UnitCount and .5 being the
UnitSize.
Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*




then I do not understand why you want to store the number so it can have
decimals places ...

Sorry. Maybe this is clearer:
The field can be Null or store values with decimal places but never 0
or less than 0.

Thanks for the tips!!!
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 -
 
J

JohnLute

Yeah. I goofed. I meant to say no decimal places. Sorry. This whole problem
involves two other fields and I'm getting a bit twisted up.
 
J

John W. Vinson

It's a field for a whole number that represents just what its field name
implies - a unit count. It can be null but never a decimal, 0 or less than
zero. For example, 10/.5 gal. 10 being the UnitCount and .5 being the
UnitSize.

I'd be inclined to use an Integer or Long Integer number for any sort of
count, rather than a Double (unless of course you need counts over the two
billion odd that a Long supports). The cost of type conversion to multiply a
Long by a Double is trivial.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top