Question : Inserting null value using currentproject.connection.<wbr />execute

This code works well unless the setdate field or the willpaydate field has a null in it. How do I modify this string to allow nulls to be inserted?
Code Snippet:
1:
2:
3:
4:
Dim strCommand As String
strCommand = "INSERT INTO [call] ([loannumber], [comments], [set],[date],[time],[user], [willpay]) "
strCommand = strCommand + "VALUES ('" + CStr(LnNo) + "', '" + commentsStr + "', '" + Format(setdate, "Short Date") + "', '" + Format(Date, "Short Date") + "', '" + Format(Time(), "hh:mm:ss AMPM") + "', '" + username + "', '" + Format(Willpaydate, "Short Date") + "')"
CurrentProject.Connection.Execute strCommand, , adCmdText

Answer : Inserting null value using currentproject.connection.<wbr />execute

try:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Dim strCommand As String,sd,wp
sd="NULL"
wp="NULL"
If Not isNull(Willpaydate) Then
	wp = "'" & Format(Willpaydate, "Short Date") & "'"
End If 
If Not isNull() Then
	sd = "'" & Format(setdate, "Short Date") & "'"
End If 
strCommand = "INSERT INTO [call] ([loannumber], [comments], [set],[date],[time],[user], [willpay]) "
strCommand = strCommand + "VALUES ('" + CStr(LnNo) + "', '" + commentsStr + "', " + sd + ", '" + Format(Date, "Short Date") + "', '" + Format(Time(), "hh:mm:ss AMPM") + "', '" + username + "', " + wp + ")"
CurrentProject.Connection.Execute strCommand, , adCmdText
Random Solutions  
 
programming4us programming4us