The Problem with Null

bloodycape

New member
Local time
Yesterday, 23:16
Joined
Aug 16, 2005
Messages
6
Ok I have a function that takes in two parameters.

Function(Text, Number)

The text comes from a table field with the same name, and the number is the result of a calculation. My problem is when there is nothing typed in the Text Field, the function craps out.

I thought I could fix this by simply adding something like
--IIF(IsNull([Text])=False, RunFunction, " ")--
to the command box in the report, that way if the Text field was empty the function would not run and simply display a blank space.

If there is a simple solution to this that can be done in the report parameters, let me know. But if it's something I have to handle in the VBA code for the function, I will go bother someone else on a totally different forum.
 
Why not check inside your function to see if the paramter is null - if so return an empty string (or whatever). The text box on the report then has its control source set to your function as normal?
 
If you still need the function to run then do this:

myfunction(nz(Mytext),mynumber)

However, if you do not want it to run if it is null then you need to do this:

If isnull(Mytext) then
exit sub (or other stuff)
else
myfunction(Mytext,mynumber)
end if

Sam
 

Users who are viewing this thread

Back
Top Bottom