Results 1 to 5 of 5

Thread: Inserting Null date

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    55

    Smile

    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

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Why do you need a Null date?

    If the field is set as Required = No then surely there shouldn't be a problem?
    Mark
    -------------------

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    55

    Red face

    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]

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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
    Mark
    -------------------

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    55
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width