Results 1 to 3 of 3

Thread: Date field is optional

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Littlehampton, W Sussex GB
    Posts
    203
    I have a date field in my access database linked to a text box on my form. When the user deletes the date - how do I put a null field into my text bos so that when I update it is not invalid?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'Convert NULL Values to Empty Strings to Avoid Errors

    'One way to avoid errors from occurring when retrieving NULL values from a recordset object is to inspect the field's value.
    'If it is NULL, then convert it to an empty string or zero. For example:

    If isnull(rs("Field")) then tmp="" else tmp=rs("Field") form.textfield=tmp

    'An even simpler way is to use the format function, which will convert a NULL value to an empty string automatically, avoiding any error messages.
    'It will look like this:

    form.textfield=format(rs("Field"))
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    An even simpler way is to disallow the use of Nulls at the table level and then just validate the user input.

    NULLS ARE EVIL!!!

    Seriously, avoiding them will save a lot of hassle.

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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