Results 1 to 4 of 4
  1. #1
    RichardS is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    2

    Exclamation Criteria Issue

    I am new to the forums and I hope someone can help me with what seems like a simple issue. I need to exclude records in a query where the PMGenerated field equals N/A. Simple enough, I just use <> "N/A" and it works. However, when I try to use a booleon field (PMOnly) on a form to determine if I should exclude them, the query will not return any records, eventhough it should.

    Here is the SQL view when using the criteria of <> "N/A" and the query works properly and returns 17 records.



    SELECT LateWorkOrders.*, LateWorkOrders.PMGenerated
    FROM LateWorkOrders
    WHERE (((LateWorkOrders.PMGenerated)<>"N/A"));

    When I add in the reference to the form, and try to get the query to select records that do not contain N/A when the PMOnly field is set to Y, the query will not return any records when it should return 17.

    SELECT LateWorkOrders.*, LateWorkOrders.PMGenerated
    FROM LateWorkOrders
    WHERE (((LateWorkOrders.PMGenerated) Like IIf([Forms].[MainForm].[PMOnly]="Y",(LateWorkOrders.PMGenerated)<>"N/A","*")));

    If I set PMOnly to N or anything else, it returns all records as it should.

    This is probably something simple, but it is driving me nuts. Any help will be sincerely appreciated.

    Richard

  2. #2
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Richard,

    First thing is you are return the same field twice.

    Code:
    SELECT LateWorkOrders.*, LateWorkOrders.PMGenerated
    FROM LateWorkOrders
    should be:

    Code:
    SELECT LateWorkOrders.* FROM LateWorkOrders
    Your where clause logic goes not make sense.

    If Forms].[MainForm].[PMOnly]="Y" is true the you would get this:

    Code:
    WHERE (((LateWorkOrders.PMGenerated) Like (LateWorkOrders.PMGenerated)<>"N/A";
    This is not valid use of the Like


    Try something like this
    Code:
    SELECT LateWorkOrders.*, 
    IIf([Forms].[MainForm].[PMOnly]="Y",(LateWorkOrders.PMGenerated<>"N/A"), True) as Selected 
    FROM LateWorkOrders WHERE Selected = True;
    *** Warning *** Air Code *** Untested
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  3. #3
    RichardS is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    2

    Exclamation

    Thanks for the response. Unfortunately, this did not help me. I redid my query to get the criteria from a form control. I think this will be cleaner anyway, but I am still running up against the same problem.

    My form control name is PMOnly.
    My criteria in the query is Forms.MainForm.PMOnly

    In my query, I need to be able to include or exclude records where Field PMGenerated equals or does not equal N/A. I can get the query to return the correct records when PMOnly is equal N/A.

    But when I set the PMOnly control to <> "n/a", <> n/a, <> n/a, or not "n/a" the query does not return any records. If I hard code the criteria to <> "n/a" or not "n/a" it works fine, but not if the criteria references the form control with the same value. I am willing to bet this is an issue with quotes, but I cannot figure it out.

    Can anyone assist me? Any help will be appreciated.

    Richard

  4. #4
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    I am still not totally clear on what you are doing.

    Again we need to see the SQL and probably more about the form design.

    It would be really make it easier to help you if you would post a sample of the database.
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

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

Similar Threads

  1. Need help with date issue.
    By ITChevyUSSNY in forum Reports
    Replies: 13
    Last Post: 02-05-2013, 10:06 AM
  2. Reporting Issue
    By watzmann in forum Access
    Replies: 1
    Last Post: 08-30-2010, 08:16 PM
  3. Criteria or Filter Issue
    By MichaelW in forum Queries
    Replies: 1
    Last Post: 07-06-2010, 01:43 PM
  4. Combo box Issue
    By desireemm1 in forum Access
    Replies: 2
    Last Post: 09-06-2009, 03:56 PM
  5. SetFocus Issue
    By Sinjin in forum Access
    Replies: 0
    Last Post: 02-14-2008, 07:31 AM

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