Information générale
Catégorie:
Codage, syntaxe et commandes
>>I would like to store a Blank date into a table column that
>>was declared as a date/Time field.
>>
>>I use the INSERT statement to insert a row of record into the
>>Table. How can I specific an empty date?
>>
>>I knew that when inserting a date, I need to quote it with
>>#4/7/2000", what about an empty date? Is it # / / #?
>>But I got error by doing that and also I tried a NULL value
>>also no luck. Any advise, thanks.
>
>Null should work! Which database engine? If Access, is your field Required property set to True.
I'm using Access 2000 and the "Required" field property was set to "No".
Dim dDTCDate As Variant
If chkDTCDate Then 'if required a date
'dtpDTCDate is a Date Picker control, this
dDTCDate = "#" & dtpDTCDate.Value & "#"
Else
''**problem lie here, I didn't put a quote as "Null"
dDTCDate = Null
End If
cnn1.Execute "INSERT INTO CustVisit(IndexNo, DTCDate) " & _
"VALUES('" & dcIndexNo & "'," & dDTCDate & ")"
It is OK now, thank you very much.
Another question, is it alright to declare the "dDTCDate" variable
as a "Variant"? Or should I declare as a "String"? Thanks.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement