What I always keep forgetting about IsMissing

like using IsMissing when appropriate on the argument list of a subroutine or function.  But I keep forgetting that I have to then declare that variable as a variant.

Good: Sub SendQuerytoExcel(strQuery As String, Optional strXLSName As Variant, Optional strSheetName As Variant)

Bad: Sub SendQuerytoExcel(strQuery As String, Optional strXLSName As String, Optional strSheetName As String)

If you forget then the string comes in as a zero length string, that is "".   And, of course, it's not missing.  Yes, yes, I know the help tells you this. It's just that i keep forgetting.

And it sure would be nice if the Microsoft Access team could put this in the VBA compiler.  After all if a field is optional it must be variant to be of any use.

My apologies if this is a duplicate as the blog server lost this entry so I had to repost it.

Published Sat, Aug 4 2007 14:15 by Tony
Filed under: , ,

Comments

# re: What I always keep forgetting about IsMissing

"it sure would be nice if the Microsoft Access team could put this in the VBA compiler"

AFAIK the Microsoft Access team do not 'own' the VBA compiler.

Jamie.

--

Friday, August 10, 2007 10:14 AM by Jamie Collins

Leave a Comment

(required) 
(required) 
(optional)
(required)