Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2003
    Posts
    233

    Unanswered: using a ckbox for a date field

    If i set the data source of a ckbox to a date field from the data source will it be checked ONLY on records with a value? and not checked only on fields that are null?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Use an Iif() statement
    Code:
    Iif(IsNull(myDateField), 1, 0)
    That should do it methinks
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I would gone:

    Code:
    =IIf(IsNull(myDateField), 0, 1)
    Myself
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hehe, I had it that way and then edited the response!
    ST's arrangment gives the correct result, mine did the opposite!
    George
    Home | Blog

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    how about
    = not isnull(myDateField)

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'm not entirely sure (and cant check because my home copy of Access needs re-installing... Thanks Office 2007!); but memory serves that checkboxes don't actually like true/false boolean values, but instead wants the integer equivalent.

    Could be wrong; could some kind soul try it and let us know?
    George
    Home | Blog

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    interesting viewpoint George.
    i would argue the inverse: that the "correct" Access use is bools to fire chkboxes, and that anything else is exploiting Access internals that are not guaranteed to remain constant (akin to using 1+Now() for this time tomorrow).

    your iif() will work, but only because of Access internals which more-or-less amount to:
    False is defined as all bits 0
    True is defined as (Not False)
    ...so your 1 is interpreted as Not False = True

    ...someone will shoot one or both of us down in flames sooner or later.

    izy
    currently using SS 2008R2

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I've mostly used 0 and -1

    ex: If me!MyCheckboxField = 0 then me!MyCheckboxField = -1 else me!MyCheckboxField = 0

    =IIf(IsNull(myDateField), 0, -1)??

    and also use 0 and -1 for values in the rowsource of a combobox for a Yes/No type field. ex: 0;No;-1;Yes.

    But then I've also used True/False as well in other criteria.
    Last edited by pkstormy; 01-16-08 at 16:12.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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