我正在尝试查找指定的列是否具有空值或者没有data.if列中存在空值,然后向用户提供消息框,说明列包含空值。 我的vba
Dim sqlid As String
Dim rst As Recordset
Dim cdb As Database
Set cdb = CurrentDb
SQLEID = "SELECT * " & _
"FROM table_1 ;"
'
Set rst = cdb.OpenRecordset(sqlid , dbOpenSnapshot)
Do While Not rst.EOF
If IsNull(rst.Fields("column1").Value) Then
MsgBox "Has nulls"
End If
Loop
rst.Close
Set rst = Nothing
Set cdb = Nothing
但是当我正在运行时,我的访问权限没有响应。如何使用vba检查列是否有任何空值
答案 0 :(得分:1)
它挂起,因为你的记录集没有增加,你需要一个MoveNext
Do While Not rst.EOF
If IsNull(rst.Fields("column1").Value) Then
MsgBox "Has nulls"
End If
rst.MoveNext
Loop
Simoco有更好的建议来实现这一目标,
If DCount(1, "table_1", "IsNull([column1])")>0 Then
MsgBox "Has nulls"
End If