Re: Query from a Combo box for both equal to and not equal to.



Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

Since I did not know the name of your field I just made up a field name.

The following should work IF the values returned by the combobox are what
you say. Try adding Forms!Main!Combo to the select list and seeing what is
actually being returned.
SELECT Gang.*, [Forms]![Main]![Combo]
FROM Gang

If you are getting the values you expect then the following should work

SELECT Gang.*, [Forms]![Main]![Combo]
FROM Gang
WHERE ([Gang].[Base]="H Base" And [Forms]![Main]![Combo]="H base") Or
([Gang].[Base]<>"H Base" And [Forms]![Main]![Combo]="No H base") Or
([Forms]![Main]![Combo]="All")


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"TomK" <TomK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:19DCE9CA-BFC4-4342-8530-ACF423401F26@xxxxxxxxxxxxxxxx
I can't get it to work:
atm i have

WHERE ((([Gang]![Base]="H Base" And [Forms]![Main]![Combo]="H base") Or
([Gang]![Base]<>"H Base" And [Forms]![Main]![Combo]="No H base") Or
([Forms]![Main]![Combo]="All")))

But it never returns any results.

I wasn't sure what you ment by SomeField i assume it is the Base filed i
am
tring to filter?

Thanks for any help

Tom


"John Spencer" wrote:


(SomeField = "H" and [Forms]![Main]![Combo] = "H")
OR (SomeField <> "H" and [Forms]![Main]![Combo] = "no H")
OR ([Forms]![Main]![Combo] = "ALL")


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"TomK" <TomK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A557B22C-27E9-43A6-A705-2283484B2C10@xxxxxxxxxxxxxxxx
Ihave a combo box which has the options 'H', 'no H' and 'All'
I want it to 'filter the base column'

In my query i basically want:

IIf([Forms]![Main]![Combo] = "no H",<>"H","H")

Or [Combo]="All"

I did have
WHERE (((Gang.Base)=[Forms]![Main]![Combo])) OR
((([Forms]![Main]![Combo])="All"))
which works fine but when i try to incorporate an iif statement it goes
wrong. The problem seams to be the <> bit. I don't think im getting the
syntax right but everything i've tried has failed.

Thanks for any help

Tom





.



Relevant Pages

  • Re: DCount function for filtered data in table
    ... Access MVP 2002-2005, 2007-2008 ... "John Spencer" wrote: ... Here is the master formula that I use in the query field that filtered ... How can I use this formula to direct Access to filter out the date for ...
    (microsoft.public.access.queries)
  • Re: Query: YTD Total with zero value
    ... Although I really think that YTD SUM would more likely be calculated in the SELECT clause while the monthly amounts would be calculated in the TRANSFORM clause. ... University of Maryland Baltimore County ... "John Spencer" wrote: ... Can you post the SQL of your query? ...
    (microsoft.public.access.reports)
  • Re: Trim Data
    ... Center for Health Program Development and Management ... University of Maryland Baltimore County ... "John Spencer" wrote: ... The query does run and returns all other fields correctly except this one ...
    (microsoft.public.access.queries)
  • Re: Query returning negative number - whats wrong with this SQL?!
    ... University of Maryland Baltimore County ... Emelina Bumsquash wrote: ... the SQL you've kindly done below isn't working in my query - it's saying there's the 'wrong number of arguments used with function in query expression.... ... "John Spencer" wrote: ...
    (microsoft.public.access.queries)
  • Re: DCount function for filtered data in table
    ... Access MVP 2002-2005, 2007-2008 ... Here is the master formula that I use in the query field that filtered out ... How can I use this formula to direct Access to filter out the date for ... "John Spencer" wrote: ...
    (microsoft.public.access.queries)

Loading