Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103

    Question Unanswered: Criteria in select query

    I want to populate the criteria section of a select query with "N" Or "F" to return the correct data. However, I also want the criteria to be determined by selection of option buttons on a form.

    So, in the criteria section of the query I have an IIf («expr», «truepart», «falsepart») expression that should look something like this:

    IIf([Forms]![xxxxxxxx]![Frame55]="1", "N" Or "F" ,"C")

    Is there anyway to format the "then" part of my expression to return "N" OR "F" when the query runs??

    I've tried about everything I can think of!

  2. #2
    Join Date
    Dec 2002
    Posts
    60
    Try:
    "'N' OR 'F'"

    (double quote) (single quote) N (single quote) (space) OR (space) (single quote) F (single quote) (double quote)

  3. #3
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103
    Unfortunately, this doesn't work. I think because everything within double quotes is taken literally. Instead of reading N Or F, it's reading 'N' Or 'F' and since there are no records equal to 'N' Or 'F' zero records are returned.

    When you place double quotes or single quotes around a character directly in the criteria section, they're not read literally - I guess.

  4. #4
    Join Date
    Sep 2003
    Location
    Lancashire, UK
    Posts
    22
    Put this as the criteria

    Like IIf([Forms]![xxxxxxxx]![Frame55]="1", "[NF]" ,"C")

    That should work

  5. #5
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50

    Re: Criteria in select query

    Hi,

    I've had a similar problem this is why the query won't return results
    SELECT Table3.ID, Table3.Field1
    FROM Table3
    WHERE (((Table3.Field1)=IIf([FORMS]![FORM1]![frame1]="1",(Table3.Field1)="N" Or (Table3.Field1)="F","C")));

    the query is trying to read Table3.field1=(Table3.Field1)="N" Or (Table3.Field1)="F" because of the IIF statement. Normally if you would just put "N" or "F" in the criteria it would return results because it's

    SELECT Table3.ID, Table3.Field1
    FROM Table3
    WHERE (Table3.Field1)="N" Or (Table3.Field1)="F";


    I haven't been able to find a work around to this yet.

    Originally posted by JamesB
    I want to populate the criteria section of a select query with "N" Or "F" to return the correct data. However, I also want the criteria to be determined by selection of option buttons on a form.

    So, in the criteria section of the query I have an IIf («expr», «truepart», «falsepart») expression that should look something like this:

    IIf([Forms]![xxxxxxxx]![Frame55]="1", "N" Or "F" ,"C")

    Is there anyway to format the "then" part of my expression to return "N" OR "F" when the query runs??

    I've tried about everything I can think of!

Posting Permissions

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