How to create an error message if the data cannot be convert to number?

  • Thread starter Thread starter nesster13
  • Start date Start date
N

nesster13

Does anybody know how to create an error message if let say I want to
conver "afsdf" into a number. I used the Val([FieldName]) but all it
does was set the data to "0" if it cannot convert to number.
 
AFAIK, the Val function doesn't raise an error if what's passed to it isn't
numeric: it's intended to return the numbers contained in a string, so if
there are no numbers, it returns 0 (as you've found)

You could try using the IsNumeric function to determine whether or not the
input is legitimate, but be aware that that function may not always return
what you're expecting. For example, IsNumeric("1e5") will return True, since
Access sees that as 10000
 
A member named chasteen suggested to use Clng([YourField]). I have
tried this out and it does output #error if the number cannot be
convert into value. thanks for the help though
 

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

Back
Top