Results 1 to 9 of 9
  1. #1
    Thadeus1991 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    7

    Question I want a calculated field in a query to appear as a check-box. How can this be done?

    Good morning everybody,



    I have written the following expression in a query, asking the question if the difference between a date and today is 12 months or less:

    12_month_limit: IIf(DateDiff("m",[Most recent audit date],Now())<=12,True,False)

    The formula works and outputs either 0 or -1.

    However, I would like the output to appear as a checkbox in the query, rather than 0 & -1. When looking at the property sheet section Lookup --> Display Control, currently "Text Box" is selected. The other options are "List Box" and "Combo Box". Unfortunately, check-box does not appear.

    Does anyone know how to change the output to check boxes, rather than 0 &-1?

    Thank you for your help!!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Might be better not to open the query directly but use the query as the Record Source of a form. The calculated field could then be used as the Control Source of a check box control.
    FWIW I would never allow users direct access to a query. I consider that to be a recipe for disaster.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Thadeus1991 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    7
    Quote Originally Posted by Bob Fitz View Post
    Might be better not to open the query directly but use the query as the Record Source of a form. The calculated field could then be used as the Control Source of a check box control.
    FWIW I would never allow users direct access to a query. I consider that to be a recipe for disaster.
    Thanks for the tip!

    I agree with you: I would not allow users access to queries either - that could be disastrous. However, the database is used by me and a colleague (both of us with similar skill levels of Access) only.
    I'd prefer to use a query rather than a form since queries can be adjusted very easily and quickly to get an Excel output (e.g. hide or show certain fields).

    If creating a form is the only way, I could, of course, do that but it'd be a lot more usable and convenient in my case if somehow the formatting of the query field can be changed to check-box!

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Have you considered using a datasheet type of form. The columns are easily hidden.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Thadeus1991 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    7
    Quote Originally Posted by Bob Fitz View Post
    Have you considered using a datasheet type of form. The columns are easily hidden.
    If I did that, would the Excel output look the same as with a query?

    In particular:
    If I export a query with tick boxes (not from a calculated field but simply from a table), they appear in Excel as "TRUE" or "FALSE" and are interpreted by Excel as numbers, not text.
    Would this be the same from a report with tick boxes?

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    If I export a query with tick boxes (not from a calculated field but simply from a table), they appear in Excel as "TRUE" or "FALSE" and are interpreted by Excel as numbers, not text.
    Would this be the same from a report with tick boxes?
    I don't know. Perhaps you could try it and let us know the outcome.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Thadeus1991 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    7
    Just tried it, unfortunately, they are exported as -1 or 0, not TRUE/FALSE.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    What results do you get if you change
    Code:
    12_month_limit: IIf(DateDiff("m",[Most recent audit date],Now())<=12,True,False)
    To
    Code:
    12_month_limit: IIf(DateDiff("m",[Most recent audit date],Now())<=12,"True","False")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Thadeus1991 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    7
    It does appear as True and False in the query output as well as in Excel.

    Excel does however interpret these as words, not as values, so I cannot do arithmetic with them :-/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-03-2016, 06:54 PM
  2. Replies: 3
    Last Post: 12-10-2015, 03:51 PM
  3. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  4. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  5. Replies: 3
    Last Post: 12-04-2012, 05:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums