Inputbox

  • Thread starter Thread starter alvin Kuiper
  • Start date Start date
A

alvin Kuiper

Hi!
In excel i have Application.inputbox
how can i in acces be sure that my inputbox contains a Number
because if i cancel my inputbox i get an error

Thanks
 
how can i in acces be sure that my inputbox contains a Number
Have you tried the Isnumeric function?

Ben
 
I'm assuming you have a numeric variable and you're setting it equal to the
InputBox result, like:

myNum = InputBox(...)

The problem with this is that if they cancel or enter anything non-numeric
it will generate an error. There may be better ways of doing this, but what I
do is declare a String variable and then check the value of it, e,g,

dim strNum as String
dim myNum as Integer (or whatever type you need it to be)

strNum = InputBox(whatever you have here)
if not isnumeric(mynum) then
do what you want to do here if it's not numeric ...
else
myNum = CInt(strNum) change this to the appropraite conversion
function
end if

Someone else may have a better way, but something like that should work for
you.
 
Back
Top