dimarts, 5 d’agost de 2014

Is Null in VBA


If you are an absolute beginner -like me- in VBA the most normal is you try to use IS NULL to find a cell without values:

            While Not rs.EOF
                If rs![Resp] is null Then
                    z = z + 1
                Else
                    i = i + 1
                End If
            rs.MoveNext
            Wend

But it won't work...

You can solve it by using IF IS NULL ( ) THEN like in this sample

            While Not rs.EOF
                If IsNull(rs![Resp]) Then
                    z = z + 1
                Else
                    i = i + 1
                End If
            rs.MoveNext
            Wend

Cap comentari:

Publica un comentari a l'entrada