Re: Integrating the code for a max.date function with a check box controlling it and

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Dear Chris:

I've reformatted your second WHERE clause here, removing some of the
unnecessary parentheses (probably those added by Access when it mangles your
query:

WHERE
([forms]![multi query]![check60] = False
AND Cost.[Date of Research] = (select max([Date of Research]) from cost
where cost.[Plant and Machinery ID] = Transaction.[Plant and Machinery
ID]))

OR

(Cost.[Date of Research] = (select max([Date of Research]) from cost
where cost.[Plant and Machinery ID] = Transaction.[Plant and Machinery
ID])
AND Transaction.Basket = True)

Sometimes, seeing the logic of what you've done can have an effect on your
view of what might be wrong.

Now, you say:

when basket = TRUE (on the form) return only the records containing a TRUE
basket check box but when 'basket' on the form = false the query is to
return all records wether they contain a TRUE value or a FALSE.

I do not see where you have tested "Basket on the form". Perhaps this is
chekc60? When you have a control you want to reference elsewhere, it's good
to name the control according to its function, not only so that others (like
myself) can tell what you intend, but to avoid making some mistake yourself.
Just a suggestion, eh.

Now, I assume next that "records containing a TRUE basket check box" refers
to a boolean column in the table Cost. Is that correct? If so, where in
this query fragment did you test that column?

The logic I would use to test this would look something like this:

WHERE (Cost.Basket = -1 OR [forms]![multi query]![check60] = 0)
AND . . .

This construction is not immediately intuitive, but I believe it is correct
and is fairly minimal. If the Basket column is checked (true), then the
test is true, whether or not the Basket on the form is checked. If the
Basket on the form is unchecked, the result is true whether the column in
the table is true or not. The only time this will exclude a row is when the
column is unchecked and the check box on the form IS checked. Isn't that
just what you want?

By the way, the value of TRUE is -1 for Access Jet databases, with respect
to both columns in tables and checkboxes on forms.

Please let me know if this helped, and if I can be of any other assistance.

Tom Ellison


"Chris W via AccessMonster.com" <u12677@uwe> wrote in message
news:55b37e8318c02@xxxxxx
> Hi all
>
> I have a problem with integrating some code I received via a previous post
> for linking a check box to a max.date function: this is the max date
function
> code: (note: this is only the WHERE statement from the SQL code as the
full
> code is very long and not all together necessary, when ever I put it in a
> post it seems to scare people off)
>
> WHERE (((Cost.[Date of Research])=(select max([Date of Research]) from
cost
> where cost.[Plant and Machinery ID]=Transaction.[Plant and Machinery
ID])))
> OR (((Cost.[Date of Research])=(select max([Date of Research]) from cost
> where cost.[Plant and Machinery ID]=Transaction.[Plant and Machinery ID]))
> OR [Forms]![FormName]![CheckBoxName] = True)
>
> The problem that I am having now is that it fails to integrate with
another
> feature of the query, which is another check box 'basket'. The function
says
> that when basket = TRUE (on the form) return only the records containing a
> TRUE basket check box but when 'basket' on the form = false the query is
to
> return all records wether they contain a TRUE value or a FALSE.
> My code as it is prior to the addition of the second checkbox is,
>
> WHERE ((([forms]![multi query]![check60])=False) AND ((Cost.[Date of
Research]
> )=(select max([Date of Research]) from cost where cost.[Plant and
Machinery
> ID]=Transaction.[Plant and Machinery ID]))) OR (((Cost.[Date of
Research])=
> (select max([Date of Research]) from cost where cost.[Plant and Machinery
ID]
> =Transaction.[Plant and Machinery ID])) AND ((Transaction.Basket)=True))
>
> So I need it to operate together when basket is selected only records
where
> basket=true are returned and when basket and the checkbox to disable max.
> date function is true it returns all date for records where basket = true
and
> so on..for all the combinations of the two check box's
>
> I would dearly love to know how to integrate them to create a statement
that
> works, thanks for any help that you can offer I really appreciate it.
>
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200510/1


.



Relevant Pages

  • Re: Attaching a check box to a max date function
    ... A somewhat complex SQL statement indeed... ... but let's focus then on the WHERE clause that you posted: ... only want to return records where Basket is True if the "basket checkbox" (I ... > false i.e. blank the query is to return all records whether the records ...
    (microsoft.public.access.queries)
  • arrays and mySQL querys
    ... I can't get an $arrayto be used as a select query on a mySQL database. ... At the bottom of the table is a submit to basket Button ...
    (comp.lang.php)
  • RE: Searching 5 or 6 excel files for specific data...
    ... Then you can query out whtever your ... Not to mentionit puts all of your data in one basket... ... "Scott" wrote: ...
    (microsoft.public.excel.programming)
  • Re: arrays and mySQL querys
    ... > I can't get an $arrayto be used as a select query on a mySQL database. ... > The basket page needs to pull these requsted rows from the database. ... of $basket in the SQL statement. ...
    (comp.lang.php)
  • Re: File sharers buy more CDs (?)
    ... increase at the same rate in the "basket" and maintain its ... but the complaint that CDs are horribly overpriced implies that they ... Overpriced implies huge profit margins. ... The cost of manufacturing CDs ...
    (rec.music.classical.recordings)