Results 1 to 13 of 13
  1. #1
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176

    Query gives right answer but asks for parameter that isnt needed?

    So I might be committing a no no but I want a query with 2 numbers and the percent of those 2, I have:

    SELECT
    Sum(COAll.[Change Order Sum]) AS [SumOfChange Order Sum],
    Sum(COAll.[Contract Amount]) AS [SumOfContract Amount],
    [SumOfChange Order Sum]/[SumOfContract Amount]*100 AS [Percent]


    FROM COAll;

    So I took fields that are being found and used them in the same query, I wasn't sure if it would work but when I ran it it asked for the parameters of [SumOf Change ORde Sum] and [SumOfContract Amout] but I just hit enter and it gives the right numbers.

    How can I make the parameter boxes not show up? Do I have to make 2 queries?

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Don't use the alias name. Use the Sum(...) statement again.

  3. #3
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    Ah that was so simple, thanks!

  4. #4
    efmbman is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    14
    Sorry if I take this on a tangent... but I have a similar problem when using nested IIF statements. I have the statement checking for a null value, then adding 6 months to a given date if true, if false another nested IIF directs to another check, and so on 11 times. For each check for null, I am prompted for a parameter.

    I don't understand the term "alias" as used in post # 2

    Thanks in advance!

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    AS [SumOfChange Order Sum] assigns an alias to the Sum(COAll.[Change Order Sum]) calculation.

  6. #6
    efmbman is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    14
    Quote Originally Posted by RuralGuy View Post
    AS [SumOfChange Order Sum] assigns an alias to the Sum(COAll.[Change Order Sum]) calculation.
    Thanks, but that is over my head. I think I may have picked a forum too advanced for my understanding.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    An alias is simply another name by which you can call an object.

  8. #8
    efmbman is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    14
    I think I should start over...

    This is what I am placing right into the query design grid:

    Follow Up Date: IIf([FormData]![StaffFU11] Is Not Null,DateAdd("m",72,[INITSTFF]),
    IIf([FormData]![StaffFU10] Is Not Null,DateAdd("m",66,[INITSTFF]),
    IIf([FormData]![StaffFU09] Is Not Null,DateAdd("m",60,[INITSTFF]),
    IIf([FormData]![StaffFU08] Is Not Null,DateAdd("m",54,[INITSTFF]),
    IIf([FormData]![StaffFU07] Is Not Null,DateAdd("m",48,[INITSTFF]),
    IIf([FormData]![StaffFU06] Is Not Null,DateAdd("m",42,[INITSTFF]),
    IIf([FormData]![StaffFU05] Is Not Null,DateAdd("m",36,[INITSTFF]),
    IIf([FormData]![StaffFU04] Is Not Null,DateAdd("m",30,[INITSTFF]),
    IIf([FormData]![StaffFU03] Is Not Null,DateAdd("m",24,[INITSTFF]),
    IIf([FormData]![StaffFU02] Is Not Null,DateAdd("m",18,[INITSTFF]),
    IIf([FormData]![StaffFU01] Is Not Null,DateAdd("m",12,[INITSTFF]),
    IIf([FormData]![INITSTFF] Is Not Null,DateAdd("m",6,[INITSTFF])))))))))))))

    For clarity, I added "returns" to show each nested IIF in a separate line. When I run the query, I am prompted for a parameter for each one... StaffFU11, StaffFU10, etc.

    I don't understand why I am being prompted for a parameter.

  9. #9
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    Me and my limited knowledge, if FormDate a table/query? Then the fields are [FormData].[StaffFU10] (with a period)

    Edit: is FormData*

  10. #10
    efmbman is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    14
    FormData is a table, yes. So replace "!" with "." is what you are saying?

  11. #11
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    Yup, also I noticed the your IIF statements don't have a closing ), not sure if that is on purpose.

    Hope that works

    Edit: nevermind about the () I see what you are trying to do

  12. #12
    efmbman is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    14
    I replaced each "!" with a "." Same result

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I think you can only nest IIF's 7 levels, but I may be wrong there. I usually use a Select Case function because they are much easier to read and maintain.

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

Similar Threads

  1. Replies: 5
    Last Post: 01-27-2013, 06:04 PM
  2. Replies: 1
    Last Post: 11-27-2012, 04:50 PM
  3. Query isnt updating table based on criteria
    By shabbaranks in forum Queries
    Replies: 12
    Last Post: 01-10-2012, 11:51 AM
  4. HELP NEEDED! Enter Parameter Value
    By lpfluger in forum Queries
    Replies: 4
    Last Post: 03-27-2011, 04:38 PM
  5. Update Query Which Asks Question
    By jhillbrown in forum Access
    Replies: 3
    Last Post: 02-15-2010, 06:36 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