Access VBA: weird result of comparison of 2 variants
Posted on 2014-07-21
In one of my Access 2007 apps, I have a comparison between 2 cells of 2 two-dimensional variant arrays, like this:
If SMD(jSMD, 33) <> sExcelData(nRow, nCol) then ... do something
The second array cell is always populated with data at this point, otherwise this particular if would be skipped. But the first array cell can be empty, indeed the idea was to put the cell content of the second array in the cell of the first one if that one was not yet filled.
To my huge surprise, following the code in debug mode, this if return false when the first array cell is Null. I would never in my wildest dreams have thought that " Null <> 'some string content' " would return anything but true !
- a huge VBA bug ?
- intended behavior ?
If the latter, I'd like a rational explanation.
I had to change all my similar if's to >> If Nz(SMD(jSMD, 33), "") <> sExcelData(nRow, nCol) then ...<< to get a propoer behavior.
Thanks for enlightening me on this one.