Results 1 to 5 of 5
  1. #1
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52

    Results of IIf Statement

    Good Morning,

    In my db, I have an unbound text box that I have the following expression in:
    [CODE]
    =IIf(Count(*)=0,"There are No Records to Display","Report for the period: " & [Enter Start Date] & " To " & [Enter End Date])
    [Code]

    This does exactly what the user wanted...until this morning. She now would like it to display the month, for example, if there are no records for August, which is possible, she would like it to say "There are No records to Display for the month of August"

    Do I need to include this in my parameter query or can it be placed in the expression?

    Thanks for any suggestions...

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't use dynamic parameterized queries. If the input is a popup then the entry on criteria row is not available for further use.

    I prefer to have user input criteria into controls on form then use VBA code to set filter of form or report.

    What is the criteria input by user? If user inputs a date range such as 8/11/2013 and 9/4/2013, the 'month' comment is not applicable.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Well, this should work:

    Format([Enter Start Date], "mmmm")

    but of course that assumes they entered the first and last days of the month.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52
    Thank you both for your response.

    June7 your example makes perfect sense, however in most cases, the report will be run over the term of 1 consecutive moth 1-31. It is a dynamic query that I'm running for this report because there will not be a need in the future to make it more than it is. Put in the dates, get the data...that's it. I was hoping to do something along the lines of what pbaldy wrote and somehow incorporate that into what I already have.

    pbaldy - your example works
    when I put it in an unbound box without the other expression. I don't know where, or if I can, insert into my existing expression.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by FormerJarHead View Post

    pbaldy - your example works
    when I put it in an unbound box without the other expression. I don't know where, or if I can, insert into my existing expression.
    In your formula:

    =IIf(Count(*)=0,"There are No Records to Display","Report for the month of: " & Format([Enter Start Date], "mmmm"))

    The Month() function would return an integer.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. IIf statement to show all results
    By nigelbloomy in forum Queries
    Replies: 5
    Last Post: 07-22-2013, 02:00 PM
  2. Replies: 3
    Last Post: 05-06-2013, 03:03 PM
  3. Replies: 5
    Last Post: 12-27-2012, 06:17 PM
  4. Hiding Results of If Statement
    By DDEB in forum Queries
    Replies: 1
    Last Post: 06-14-2012, 04:48 PM
  5. Replies: 4
    Last Post: 10-12-2010, 02:11 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