如何检查表中的空值?

时间:2022-01-28 17:06:48

USING MS ACCESS 2003

使用MS ACCESS 2003

How to check is null value in the access database?

如何检查访问数据库中的空值?

My code.

Public Function DateToString(dte As Date) As String
Dim d As String
Dim m As String
Dim y As String
d = Day(dte)
m = Month(dte)
y = Year(dte)
If Len(d) = 1 Then d = "0" & d
If Len(m) = 1 Then m = "0" & m
DateToString = y & m & d
End Function


Public Function StringToDate(txt As String) As Date
Dim dte As String
dte = Left(txt, 4) & "-" & Mid(txt, 5, 2) & "-" & Right(txt, 2)
StringToDate = CDate(dte)
End Function




sql1 = "CREATE TABLE MOI (PreDate varchar(50))"
sql2 = "INSERT INTO MOI values('" & StringToDate(rsCardEvent1.Fields("PreDate"))  "')"

From the above function, I want to check if not null then my code else no need.

从上面的函数,我想检查是否不为null然后我的代码不需要。

Need VB 6.0 Code Help?

需要VB 6.0代码帮助?

2 个解决方案

#1


To check for Null in a dataset field:

要在数据集字段中检查Null:

If IsNull(rs("colname")) Then 
  'Field contains a Null Value 
Else 
  'Field does 'not' contain a Null Value 
End If

To check for null or Empty string:

要检查null或Empty字符串:

If (txt & "") = "" Then 
  ' txt is Null or empty
End If

#2


If the item is actually coming is as a string, then do:

如果该项目实际上是一个字符串,那么执行:

if not txt is vbNullString then
    ' code here
end if

#1


To check for Null in a dataset field:

要在数据集字段中检查Null:

If IsNull(rs("colname")) Then 
  'Field contains a Null Value 
Else 
  'Field does 'not' contain a Null Value 
End If

To check for null or Empty string:

要检查null或Empty字符串:

If (txt & "") = "" Then 
  ' txt is Null or empty
End If

#2


If the item is actually coming is as a string, then do:

如果该项目实际上是一个字符串,那么执行:

if not txt is vbNullString then
    ' code here
end if