Results 1 to 7 of 7
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    Help with figuring what I am doing wrong with Query Criteria

    So, I have a query that pull up data based on Criteria on a form.


    [A?P?R?]
    Criteria: IIf([Forms]![Frm_Report_PayorMix]![FinalDecision]="*",([Referrals].[A?P?R?])<>"F/U",[Forms]![Frm_Report_PayorMix]![FinalDecision])

    I thought this will generate a <>"F/U" if the FinalDecision box = * ,otherwise, will just be the value on the FinalDecision Box




    SELECT Referrals.ReferralDate, Referrals.[A?P?R?], Referrals.CaseComplete, Referrals.RefType, Referrals.NN, Referrals.[ROC?], Referrals.Patient, Referrals.RefSource, Referrals.Zip, Referrals.Dx, Referrals.Payor, Referrals.InsSpecific, Referrals.[ACO?], Referrals.ExpHHSOC, Referrals.ExpPTEval, Referrals.ID, Referrals.DOB, Referrals.M0102, Referrals.Attending, Referrals.[BSHSIDoc?], Referrals.EnteredBy, Referrals.DeclineReason, Referrals.[SN?], Referrals.[PT?], Referrals.[OT?], Referrals.[ST?], Referrals.OtherServices, Referrals.RefProcessed, Referrals.[Bundled?]
    FROM Referrals
    WHERE (((Referrals.[A?P?R?])=IIf([Forms]![Frm_Report_PayorMix]![FinalDecision]="*",([Referrals].[A?P?R?])<>"F/U",[Forms]![Frm_Report_PayorMix]![FinalDecision])) AND ((Referrals.RefType) Like [Forms]![Frm_Report_PayorMix]![OtherRef]) AND ((Referrals.[ROC?])=False) AND ((Referrals.ExpHHSOC)>=[Forms]![Frm_Report_PayorMix]![From] And (Referrals.ExpHHSOC)<DateAdd("d",1,[Forms]![Frm_Report_PayorMix]![Thru])))


    ORDER BY Referrals.[A?P?R?], Referrals.Patient;

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Asterisk (*) is wildcard character. Are you trying to find the actual character in data? Show sample data.

    Strongly advise not to use punctuation nor special characters in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    I changed that to "ALL" and the result is the same. Not sure what I am doing wrong in the Criteria. What I want to see is: if the Como Box value = "ALL", the criteria for the query = <>"F/U", otherwise, just use the Value in the Combo Box.

    The reason why I do a <>"F/U" because I want to display everything else.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Don't know if this is missing the point, but the expression

    ([Referrals].[A?P?R?])<>"F/U"

    is a comparison and will resolve as true or false.


  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Review https://stackoverflow.com/questions/...y-returns-true

    Instead of popup input prompt shown in examples, use reference to control on form.

    Also, http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    [A?P?R?]
    Criteria: IIf([Forms]![Frm_Report_PayorMix]![FinalDecision]="*",([Referrals].[A?P?R?])<>"F/U",[Forms]![Frm_Report_PayorMix]![FinalDecision])
    you can't use iif's in criteria in this way, you use 'and's' and 'or's' with appropriate bracketing

    criteria
    <>"F/U" AND (
    [Forms]![Frm_Report_PayorMix]![FinalDecision] OR [Forms]![Frm_Report_PayorMix]![FinalDecision]="*")

  7. #7
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    I see. Ty so much. I try it and it works!!! Ty

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

Similar Threads

  1. Replies: 20
    Last Post: 01-07-2023, 08:49 AM
  2. Date serial criteria giving me wrong data
    By Gina Maylone in forum Access
    Replies: 5
    Last Post: 03-08-2019, 10:54 AM
  3. Replies: 4
    Last Post: 08-01-2016, 06:41 AM
  4. Value from DSUM with multiple criteria wrong
    By maxmaggot in forum Reports
    Replies: 4
    Last Post: 04-12-2014, 05:21 PM
  5. What's wrong with this Criteria
    By djclntn in forum Queries
    Replies: 3
    Last Post: 10-28-2013, 01:23 PM

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