Results 1 to 8 of 8
  1. #1
    RAHILTON76 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    4

    Help with IIf statement

    I'm getting an error with: =IIf([CNUM]="PERMA1",[Required], "")



    *if the Customer# = "Perma1" then show field the [Required] else blank.

    I am able to return a text string, but NOT the data that I need to display.

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    where are you using this code? in a query, a form or report or vba?

    and what does this mean?

    but the data that I need to display

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Where are you using the expression, and what is the error message?

    Just as a guess, though, a field called [CNum] would usually contain numeric data (judging by its name), and you are comparing it to a string which cannot be evaluated as a number.

  4. #4
    RAHILTON76 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    4
    In a report. I meant to say "but the NOT the data that I need to display"

  5. #5
    RAHILTON76 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    4
    I am using it in a report. The error is Invalid Control Source and Circular Reference.

    The CNUM (customer number) is a text field of 5 alphas and 1 numeric.

    if the Customer is Perma Pipe ([CNUM= "PERMA1) then show the QC ranges ([Required]) on the report, otherwise don't show anything

  6. #6
    SuperAccessNinjas is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2016
    Posts
    8
    What is the name of the text box in your report? I'm guessing if you check the Name attribute on the All tab of the property sheet, it will say CNum. With this being the case, the Iif expression is referring to itself, hence the circular reference error. Probably the easiest way to resolve is to update the Name property to be something like "CNum_Conditional". Really anything other than CNum should work.

    Feel free to reach out to info@superaccessninjas.com if you need more guidance.

  7. #7
    RAHILTON76 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    4
    Quote Originally Posted by SuperAccessNinjas View Post
    What is the name of the text box in your report? I'm guessing if you check the Name attribute on the All tab of the property sheet, it will say CNum. With this being the case, the Iif expression is referring to itself, hence the circular reference error. Probably the easiest way to resolve is to update the Name property to be something like "CNum_Conditional". Really anything other than CNum should work.

    Feel free to reach out to info@superaccessninjas.com if you need more guidance.



    YES!! I had a lightbulb moment with you said "text box"! I was attempting to add an expression to the field [REQUIRED]...thus getting a circular reference error! I added a clean text box and Voila...it worked!! I am BRAND NEW to Access...I will get this sooner or later! Thank you!

  8. #8
    SuperAccessNinjas is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2016
    Posts
    8
    Quote Originally Posted by RAHILTON76 View Post
    YES!! I had a lightbulb moment with you said "text box"! I was attempting to add an expression to the field [REQUIRED]...thus getting a circular reference error! I added a clean text box and Voila...it worked!! I am BRAND NEW to Access...I will get this sooner or later! Thank you!
    H2H lmk if you need more help 😃😃
    Andre
    Info@superaccessninjas.com

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

Similar Threads

  1. Using AND with OR in IF statement
    By bfont in forum Programming
    Replies: 2
    Last Post: 06-25-2015, 03:27 PM
  2. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. IIf Statement
    By dref in forum Forms
    Replies: 2
    Last Post: 07-16-2010, 02:46 AM

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