题
使用MS ACCESS 2003
如何检查是在访问数据库空值?
我的代码。
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")) "')"
从上面的功能,我想检查,如果不为空,然后我的代码,否则没有必要。
需要VB 6.0代码帮助?
解决方案
要在数据集中字段检查空:
If IsNull(rs("colname")) Then
'Field contains a Null Value
Else
'Field does 'not' contain a Null Value
End If
要检查空或空字符串:
If (txt & "") = "" Then
' txt is Null or empty
End If
其他提示
如果实际上是未来的项目是作为一个字符串,然后执行:
if not txt is vbNullString then
' code here
end if
不隶属于 StackOverflow