Come controllare è valore nullo nella tabella?
-
23-08-2019 - |
Domanda
con MS Access 2003
Come controllare è valore nullo nel database di Access?
Il mio codice.
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")) "')"
Dalla funzione di cui sopra, voglio verificare se non nullo, allora il mio codice resto alcuna necessità.
Hai bisogno di VB 6.0 Codice Aiuto?
Soluzione
Per verificare la presenza di null in un campo del set di dati:
If IsNull(rs("colname")) Then
'Field contains a Null Value
Else
'Field does 'not' contain a Null Value
End If
Per verificare la presenza di stringa nulla o vuoto:
If (txt & "") = "" Then
' txt is Null or empty
End If
Altri suggerimenti
Se l'articolo è in realtà venuta è come una stringa, poi fare:
if not txt is vbNullString then
' code here
end if
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow