passing null strings

  • Thread starter Thread starter Christopher Glaeser
  • Start date Start date
C

Christopher Glaeser

Given the subroutine definition "Sub CreateFax (Subject As String)" that
opens frmFax

and the subroutine call: "CreateFax Me.Subject"

the code fails at the call if Me.Subject is Null. How do I pass a Null
value? I want frmFax.Subject set to the value of Me.Subject, even if Null.

Best,
Christopher
 
Hi, Christopher.

Convert the Null string to a blank one before calling:

If IsNull(strMyString) Then
strMyString = ""
End If
Call CreateFax(strMyString)

Sprinks
 
Convert the Null string to a blank one before calling:

Wow!!!! Thanks for the assitance, but that's a shocker coming from C, where
passing Null is a language feature. This form has 12 fields (and thus 12
arguements for the subroutine definition) and is called from 6 different
command buttons. Jeepers, that's a lot of IIf expresions just to pass
potentially Null arguments. Thanks again.

Best,
Christopher
 
Changing the subroutine argument type from string to variant also solved the
problem.

Best,
Christopher
 
Hi, Christopher.

I agree with you, and I realize I gave you a bum steer. Convert it using
the NZ function during the call, eliminating the IIF statements:

CreateFax(Nz(Me.Subject,""))

Sorry for the confusion.

Sprinks
 
Sprinks said:
Hi, Christopher.

I agree with you, and I realize I gave you a bum steer. Convert it
using
the NZ function during the call, eliminating the IIF statements:

CreateFax(Nz(Me.Subject,""))

Or even

CreateFax Me.Subject & ""
 
Back
Top