Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15

    Substitute the text "ALL" on the report when the user selects all records (*) in a query

    I have report that is based is on a query. The user is prompted to enter a value, the value the user enters prints out at the top of the report. This works fine when the user enters a single value (i.e. 13, 26, etc), but I can't get it to print the text "ALL" if the user enters * for all the records. I also am a self-study to all of this, so I know there is an easier, more efficient way to do this. This is in expression builder: (REDACTED DUE TO BUSINESS PURPOSES)



    =IIf(Left([Reports]![Summary Report]![Query1.Team],1)="1*" Or "2*" Or "3*" Or "4*" Or "5*" Or "6*" Or "7*" Or "8*" Or "9*",[Reports]![Summary Report]![Query1.Team],IIf(Left([Reports]![Summary Report]![Query1.Team],1)="*","ALL"))


    I welcome the advice of those willing to teach me a better way. Enlightment is so fulfilling.

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Quote Originally Posted by Gmgraham View Post
    =IIf(Left([Reports]![Summary Report]![Query1.Team],1)="1*" Or "2*" Or "3*" Or "4*" Or "5*" Or "6*" Or "7*" Or "8*" Or "9*",[Reports]![Summary Report]![Query1.Team],IIf(Left([Reports]![Summary Report]![Query1.Team],1)="*","ALL"))
    I don't understand why you're checking for 1*, etc. Your description mentions entering a # or an *, but not both.
    An If statement must be structured as IIF [something]="value". If you're going to add 'OR' or 'AND' you'll need to do, IIF [something]="value" OR [something]="another value", etc. You are ORing everything to the right of the equals before doing the comparison. You're probably never getting to the false part of the outer IIF. What is the purpose of the outer IIF?
    Maybe the isnumeric function is what you want e.g. IIF (isnumeric(left[field],1)),[field], IIF ([field],"*","ALL",""))

  3. #3
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    @Competent Performer, thank you for replying. Like I said I'm new to this, all the 1*, 2*, etc was my newbie attempt to make sure that whatever Team the user entered in the queried printed out. If they enter *, I want to print ALL. I tried your suggestion, I'm not sure if their is an issue with synatx, or me but I get an error: "You may have entered an operand without an operator" Here is what I substituted for what I previously had. Where did I go wrong?

    Code:
    IIF (isnumeric(left[Team],1)),[Team], IIF ([Team],"*","ALL","")) 

  4. #4
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Quote Originally Posted by Gmgraham View Post

    Code:
    IIF (isnumeric(left[Team],1)),[Team], IIF ([Team],"*","ALL","")) 
    you didn't put a ( when calling the left function, and the second IIF isn't checking for '='
    try this
    IIF (isnumeric(left([Team],1)),[Team], IIF ([Team]="*","ALL",""))

  5. #5
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    Thanks again. At least that got it to print something out, I get a '#TYPE' printing in the field on the report now so something is off somewhere. Not sure if that is a design problem or what. I will keep at it.

  6. #6
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    Hi @ Competent Performer. I got the #Type error to go away. Apparently I didn't give my control a new name (typical newbie faux pas), but it still doesn't recognize when I'm inputting the "*" into the query. It works fine forevery team. however, when I enter * it will print 89.

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You may get some ideas regarding what goes on behind the scene when dealing with "ALL" from this sample.
    I realize this isn't a report example, but I'm just pointing out that you may have to intercept the user's input and do some special process to get the data you want.

  8. #8
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    Hi @Orange, thank you for your reply. This is a little different than what I actually need. Or maybe I just don't know enough to make the connection between this and printing the criteria I need on my report. However, this is good stuff and I will keep it for my future learning however.

  9. #9
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Is the statement you're trying to fix the control source for a control on a form/report, or part of a query? If a query, please show us the entire query. Where is the "*" being input?

  10. #10
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    The query works fine outside of the report. The results you gave megive me a result now that I renamed my textbox control formerly named "TEXT" to "txtbx". (Duh!!) When I run the query, it will return the results for a particular team or it will reuturn the results for all the teams if I enter *. The problem comes in when I try to format the control "txtbx" on the report. This is what I'm asking help for. If the User enters a Team number in query, i want it print that number on the report, if they query all the records, I want it to print the word "ALL". The expression you gave me works for the teams when a number is entered, but it still isn't recognizing when I query all the records. i don't understand why, because the statement is logically sound as possible. If this true then.... if this then... false. What more does it need

  11. #11
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  12. #12
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Quote Originally Posted by Gmgraham View Post
    When I run the query, it will return the results for a particular team or it will reuturn the results for all the teams if I enter *.
    Quote Originally Posted by Gmgraham View Post
    The expression you gave me works for the teams when a number is entered, but it still isn't recognizing when I query all the records.
    These two statements seem to conflict. Going back to your original post, it looks like the query is getting the value from a control on a report. Is this right? Then the results of a query provide data for a different report? I'm confused, obviously. Can you show your query? Where is the team number entered?

  13. #13
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    Unfortunately, due to business purposes. I cannot.

    In a nut-shell, I have report based on a query. My query runs fine outside of the report. It returns records for a single team or all the teams if "*" is entered. All I want on the report is the Team number if the user enters a number in the query or the word ALL if * is entered in the query

  14. #14
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Then how about on your report putting something like IIF((isnumeric([team]),[team],"ALL") for the control source of the field on the report?

  15. #15
    Gmgraham is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    15
    Ugh, same results. This doesn't makes sense. Why doesn't it see the second part of this statement? I don't get it.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 8
    Last Post: 05-15-2015, 05:11 PM
  3. Replies: 4
    Last Post: 08-26-2014, 05:52 PM
  4. Replies: 2
    Last Post: 01-03-2014, 09:35 AM
  5. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 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