Log in

View Full Version : Invalid input to a VBA function



litmus2k
01-22-2008, 03:52 PM
Is it true that if I pass an invalid argument to a fucntion, the function will still work and return the default value?
-newbee-

akn112
01-23-2008, 08:26 AM
do you mean 1) passing a null value, or 2) passing an integer to a string input.

if 1) then you might get an error, invalid use of null, or argument not optional error, not quite sure. But it's always good practice to handle nulls in your code (just add nz function at beginning).

if 2) you will get a reference error.

also depends if your passing to a user defined function or a built in one.

Norie
01-23-2008, 10:56 AM
What VBA function would you be referring to?

litmus2k
01-23-2008, 11:10 AM
lets say i have code to opne the form and pass a non-existent form as input.. how should it behave?

Norie
01-23-2008, 11:14 AM
Well if the form doesn't exist then obviously an error will occur because VBA can't find it.

There is no 'default' for such a thing.