views:

35

answers:

1

Hi All.

I am performing a query on the following table:

Approval

  • person (long int)
  • item (long int)
  • reason (long int)
  • date (date)
  • valid (bool)

The first 3 fields are linked to other tables. Each person may have any number of entries in this table, for various items, reasons or dates. I then perform the following query:

SELECT Approval.person, 
        Approval.item,
        Approval.reason, 
        Min(Approval.valid) AS valid
FROM Approval
GROUP BY Approval.person, 
        Approval.item, 
        Approval.reason;

Why? Because I am not only interested in "who has valid status", but also "who ever had an approval for this item or reason, and is this approval still valid?"

Now, this works - well, sort of. However, because I have performed a Minimum aggregate function, I have automatically changed the data-type from Yes/No to Numerical (I used the minimum aggregate function simply because I knew of no other better way to do it).

So, the question is, how do I change the numbers -1 & 0 back into a boolean value of True/False? Or, is there a better way of doing this query?

Best regards, Phil

A: 

Hi Phil

The function CBool() will change the number back into True or False

Croberts
Hi. Well, that's what I thought - but I'm obviously doing something wrong (or expecting too much), because when I execute the query with the CBool(Min(Approval.valid)) expression, i *still* do not get the expected tick-box - just the 0 and -1 figures.Can this be done?I'm using Office 2003, if this is relevant.
Phil White
i dont think it is possible to change it to a check box in the query once it has been changed to a number, is there a reason why you need the check box in the query?
Croberts
A checkbox is not a value -- it's a display issue, and queries do allow you to choose what control you use to display. In the field properties, there's a second tab for Lookup. Checkbox may be one of the choices, but it's not always reliably so (it depends on whether the field is defined as Boolean or not). But this is a presentation-layer issue, and you shouldn't be using saved QueryDefs as UI components.
David-W-Fenton
Many thanks for the comments. I've done a bit of thinking over the weekend, and a lot of re-designing - everything is now presented as a form or a report. Cheers all.
Phil White