passing null strings

  • Thread starter Christopher Glaeser
  • 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
 
Ad

Advertisements

G

Guest

Hi, Christopher.

Convert the Null string to a blank one before calling:

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

Sprinks
 
C

Christopher Glaeser

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
 
C

Christopher Glaeser

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

Best,
Christopher
 
G

Guest

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
 
Ad

Advertisements

D

Dirk Goldgar

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 & ""
 

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

Top