Results 1 to 7 of 7

Thread: Can not update NULL value.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    I have a TextBox linked to a field in a database which is a date field. When the record is first accessed the value is null. When I change the value to a valid date it is fine. However, when I try and change it back to a blank value

    me.text1.text = ""

    it gives me a data integrity error.

    Any Ideas???

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    I'm guessing that the problem is that an empty string is not the same thing as NULL. You might have to send back the value NULL instead of an empty string because of some data validation going on at the database end.

    Before sending the data back, you might try this...
    Code:
    If Text1 = "" Then
        Text1 = vbNullString
    End If
    I'm not sure this is going to fix it, but I think it's on the right track.

    Edited by seaweed on 03-08-2000 at 07:17 PM
    ~seaweed

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    I tried this but it still does not like it. Apparently once a valid date value is entered, it will only accept a valid date and not null.

    Any other ideas on how to deal with this?

  4. #4
    Guest

    Post

    You can check a null value with.

    Code:
    If IsNull(Text1.Text) Then
    And when you want to give a field a null value.
    make sure you have defined the field in de database
    to accept the null values. Mostly the default value
    is (do not accept null value).

    -Kayoca


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    The database is Access and I can not find anywhere where you designate that it is okay to accept null values. I am converting this App from Access to VB and it works fine in access forms. You can somehow place Null values in an access form but if you are using a data control in VB it treats it differently????????????

  6. #6
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281

    Post

    In Access itself, you can set the Allow Nulls property to true.

    Also, using this will change null to an empty string " "
    form.txtField=format(rs("Field"))


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    You can set a text field to allow zero length but I can not find where you can do it with a field formated as a date? I am using Access97. Are you using Access 2000? If you are using Access97 then could you be more specific and tell me how I do it.

    Thanks

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