Re: Determine if input is a decimal

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 12/13/04


Date: Mon, 13 Dec 2004 13:36:05 -0500

If Me.ControlName.Value <> CLng(Me.ControlName.Value) Then
    MsgBox "You must enter a whole number!"
End If

Note that this will work so long as the number is within the data size
limits of a Long data type. If the number will be larger than those limits,
then you may need to use InStr to search for embedded decimal point.

-- 
        Ken Snell
<MS ACCESS MVP>
"Fred Boer" <Fredboer1@NOyahooSPAM.com> wrote in message
news:%23nJJvzT4EHA.2196@TK2MSFTNGP14.phx.gbl...
> Hello!
>
> I have a student creating a form. He wants to use an AfterUpdate event to
do
> data validation. He wants only whole numbers, no decimals. He wants help
> with this and expects I know how to do this....  I said *of course* I
could,
> but that I had no time just then... ;)
>
> I suppose I might try doing something like searching for a period using
> InStr() or something, but perhaps there is a more elegant "math" function
or
> some kind of  "math" thing that can determine if a number has decimals?
>
> Note: When you read "math", invest it with all the fear, loathing,
> bewilderment and consternation you can - that's the way I say it! ;)
>
> Thanks!
> Fred Boer
>
>


Relevant Pages

  • Re: [OT] Re: Question for designers...
    ... You find it easier to multiply and divide ... Decimal metric units at least makes it ... directly since all our calculators work in decimals. ... decimal, then doing the math, and then trying to convert back to fractions, ...
    (comp.robotics.misc)
  • Re: Excel is unusable for finance or accounting.
    ... The problem isn't really in the floating-point representation of numbers, per se, or the ... Could Exel do floating-point ... The processor can't do decimal math natively, so it'd have to be done in software, ... handle simple fractions and decimals (see thread 'Glaring Excel calc ...
    (microsoft.public.excel)
  • Re: .99999... still=/= 1
    ... >>proper mathematical terminology. ... Math definition for above quote of irrational number. ... >consecutive digits repeating itself indefinitely and that cannot be expressed ... And these decimals can repeat infinitely but with a ...
    (sci.math)
  • Re: Reduce size of data
    ... Unless they have changed their minds, this has a 1 GB database size limit, ... MSDE has same limits, ... you only need 7 digits precision you could replace your Decimals with ...
    (microsoft.public.access.tablesdbdesign)
  • Re: motivating a kid into analysis
    ... >I'd like some hints from the experienced mathematicians on how I can ... My boy loves math, ... geometry -- convexity, geometric inequalities, geometric limits ... sequences and series (arithmetic, geometric, limits of sequences, ...
    (sci.math)

Quantcast