使用 access vba 检查表列是否有空值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23522812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using access vba to check if table column has null values
提问by sam
I'm trying to find if the specified column has null values or no data.if null values are present in the column then gives the message box to user saying column contain nulls. My vba
我正在尝试查找指定的列是否具有空值或没有数据。如果列中存在空值,则将消息框提供给用户说列包含空值。我的 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
But when i'm running this my access goes not responding. How do i check if the column has any nulls using vba
但是当我运行它时,我的访问没有响应。我如何使用 vba 检查列是否有任何空值
采纳答案by Jimmy Smith
It hangs as your recordset is not being incremented, you need a MoveNext
它挂起,因为您的记录集没有增加,您需要一个 MoveNext
Do While Not rst.EOF
If IsNull(rst.Fields("column1").Value) Then
MsgBox "Has nulls"
End If
rst.MoveNext
Loop
Simoco had a better suggestion for accomplishing this,
Simoco 有一个更好的建议来完成这个,
If DCount(1, "table_1", "IsNull([column1])")>0 Then
MsgBox "Has nulls"
End If