-
I am using Access Database in my VB application.
Thare is one table which contains HireDate field which is of Date data type.This Field is optional.How can i insert a null date into it using SQL Insert Statement From VB. I am using DAO and Execute method.
Thanks in Advance
-
Why do you need a Null date?
If the field is set as Required = No then surely there shouldn't be a problem?
-
Thank for repplying.
Suppose the user is not willing to supply the value right now then the value will be null string.
Actually what is going on here is
I have a text box in to which the user can enter a date.
the SQL looks like this
strSQL="INSERT INTO <table name> (<field1>,<field2>,<date field>) VALUES (" & txtField1.text & "," & txtField2.text & ",'" & txtDateField.txt &"')"
If there is no date in the txtDateField textbox Still it should work.
Now Think of it.
[Edited by gorthims on 05-09-2000 at 05:38 AM]
-
Personally I would check that the date textbox was valid first eg:
Code:
If IsDate(txtDateField.Text) Then
strSQL = "INSERT INTO <table name> (<field1>,<field2>,<date field>) VALUES (" & txtField1.Text & "," & txtField2.Text & ",'" & txtDateField.Text & "')"
Else
strSQL = "INSERT INTO <table name> (<field1>,<field2>) VALUES (" & txtField1.Text & "," & txtField2.Text & "')"
End If
-
I think that is not the appropriate solution. Because if there are are a number of optional date fields then you can not have that many no. of SQL statements(Permutations and combinations).
Please think about it and find the solution for me