점검하는 방법은 테이블에서 NULL 값입니까?
-
23-08-2019 - |
문제
MS Access 2003 사용
액세스 데이터베이스에서 NULL 값을 확인하는 방법은 무엇입니까?
내 코드.
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")) "')"
위의 함수에서, 나는 null이 아닌지 확인하고 싶습니다. 내 코드는 필요하지 않습니다.
VB 6.0 코드 도움말이 필요하십니까?
해결책
데이터 세트 필드에서 NULL을 확인하려면 :
If IsNull(rs("colname")) Then
'Field contains a Null Value
Else
'Field does 'not' contain a Null Value
End If
NULL 또는 빈 문자열을 확인하려면 :
If (txt & "") = "" Then
' txt is Null or empty
End If
다른 팁
항목이 실제로 오는 경우 문자열이라면 다음을 수행합니다.
if not txt is vbNullString then
' code here
end if
제휴하지 않습니다 StackOverflow