Results 1 to 12 of 12
  1. #1
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476

    Why am I being asked to enter a Parameter Value...?

    SELECT [Employees Payroll Query].epEmployeeID AS EmployeeID, Max([Employees Payroll Query].epDate) AS LastDateWorked, [LastDateWorked]-Date() AS DaysSinceWorked
    FROM [Employees Payroll Query]
    GROUP BY [Employees Payroll Query].epEmployeeID, [LastDateWorked]-Date()
    HAVING ((([Employees Payroll Query].epEmployeeID) Is Not Null))
    ORDER BY Max([Employees Payroll Query].epDate) DESC;




    Enter a Parameter Value for LastDateWorked

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Because the GROUP BY clause is evaluated before the SELECT clause. You'll need to repeat the Max there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    I don't quite follow. I tried putting Max after GROUPP BY, but that didn't work. Might youb be kind enough to send back the correct SQL?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    See if this works:

    SELECT [Employees Payroll Query].epEmployeeID AS EmployeeID, Max([Employees Payroll Query].epDate) AS LastDateWorked, [LastDateWorked]-Date() AS DaysSinceWorked
    FROM [Employees Payroll Query]
    GROUP BY [Employees Payroll Query].epEmployeeID, Max([Employees Payroll Query].epDate) -Date()
    HAVING ((([Employees Payroll Query].epEmployeeID) Is Not Null))
    ORDER BY Max([Employees Payroll Query].epDate) DESC;

    Might need the same thing in the SELECT clause on the other field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    It's telling me:
    Cannot have aggregate function in GROUPBY clause Max([Employees Payroll Query].epDate) -Date()

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Testing would indicate I made a mistake there.

    I could swear I've done that, but perhaps not. What happens if you drop that bit from the GROUP BY clause completely? In design view, that would mean changing Group By to Expression. If that doesn't work, you may need to create one query that just groups on employee and returns the max date, and then base a second query on that one.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    It Worked. Thanks!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem; sorry about leading you down the wrong path.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    pd: Can I ask you A ? regarding spcl chrctrs. In a query you can remame any fld name by putting a : after the chosen name - eg. X\X: Does this mean that I can then use spcl chrctrs then, or is it still wise not to do so?

    I hope you unstand my shorthand

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You can often get away with it, but I never do. My thinking is, why risk it? You can put anything in a form/report label for user clarity. From this link:

    http://support.microsoft.com/default...b;EN-US;209187

    The following symbols must not be used as part of a field name or as part of an object name:

    . / * : ! # & - ? ; " ' $
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Paul, sorry if I'm bugging you here. 2-quick ?'s

    1. \ is not a spcl chrctr that's weird...? Funny thing is I used that particular character a lot, but have been stopping & going back & changing my fld names.

    2. I believe to be right from experience, but I want to make sure. Say in a query I have a field name, psW which I changed to be, W: [psW] If I need to refer to this field in a cacl/expression I can just refer to the W, or ought I be referring to, psW?

    Thanks a lot for your time!
    Dave...

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I wouldn't use the \ either, as if you tried to use the field in a file path you'd be hosed. Like I said, you can often get away with it, but why risk it?

    Within the query, it depends. You'll sometimes be able to refer to the alias in other field calculations in the SELECT clause, but not in other clauses, as you discovered above.
    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. Enter Parameter Value
    By kwooten in forum Queries
    Replies: 13
    Last Post: 08-11-2011, 02:35 PM
  2. Enter Parameter value?
    By hlcarlin in forum Forms
    Replies: 3
    Last Post: 07-06-2011, 08:09 AM
  3. enter parameter value
    By alliandrina in forum Access
    Replies: 1
    Last Post: 06-05-2011, 01:02 AM
  4. Replies: 3
    Last Post: 02-27-2009, 08:07 PM
  5. Enter Parameter Value
    By plesser in forum Access
    Replies: 1
    Last Post: 11-08-2008, 10:27 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