I have a query that runs fine. BUT when I try to have the last field sort in descending order, then when I try running the query, then it asks me for values of a parameter.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Query is fine, but when sorted then requests parameters
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Query is fine, but when sorted then requests parameters
- This topic has 9 replies, 3 voices, and was last updated 9 years, 4 months ago.
AuthorTopicWSjlwood44
AskWoody LoungerJanuary 9, 2016 at 3:53 pm #503978Viewing 6 reply threadsAuthorReplies-
WSjlwood44
AskWoody LoungerJanuary 10, 2016 at 5:12 pm #1546630SELECT Cons_FT_v4_Query.Player_ID, Cons_FT_v4_Query.Roster_ID, Cons_FT_v4_Query.Game_ID, Cons_FT_v4_Query.Skill_Level, Cons_FT_v4_Query.Full_Name, Cons_FT_v4_Query.g1_FTM, Cons_FT_v4_Query.Free_Throws_Attempted, Cons_FT_v4_Query.FT_Missed, Cons_FT_v4_Query.[Game_#], Cons_FT_v4_Query.[MaxOfGame_#], Cons_FT_v4_Query.Additional_Games, Cons_FT_v4_Query.Fall_Year, Cons_FT_v4_Query.Next_Season, Cons_FT_v4_Query.g2_Season, Cons_FT_v4_Query.Next_Game, [Roster_Info]![Roster_ID] AS g2_R_ID, [Game_Stats]![Free_Throws_Made] AS g2_FTM, [Game_Stats]![Free_Throws_Attempted] AS g2_FTA, Val(Nz([g2_FTA],”0″))-[g2_FTM] AS g2_Ms, IIf([g2_Ms]=0,[g2_FTM]+[g1_FTM],[g1_FTM]) AS g2_C_FT
FROM (Cons_FT_v4_Query INNER JOIN Roster_Info ON (Cons_FT_v4_Query.g2_Season = Roster_Info.Season_Play) AND (Cons_FT_v4_Query.Player_ID = Roster_Info.Player_ID)) INNER JOIN Game_Stats ON (Roster_Info.Roster_ID = Game_Stats.Roster_ID) AND (Cons_FT_v4_Query.Next_Game = Game_Stats.Game_ID); -
WSruirib
AskWoody Lounger -
WBell
AskWoody_MVPJanuary 10, 2016 at 6:10 pm #1546633How are you trying to sort it by the last field? Are you putting something in the property of the query, or are you putting something in the query grid? I would check to make sure there isn’t something in the “Order By” property, and put the sort in the query grid (or in the SQL statement).
-
WSjlwood44
AskWoody LoungerJanuary 11, 2016 at 9:00 am #1546671This is with the OrderBy. The parameter is Ms_g2. I seems that any positive number will make the parameter happy, AND does not seem to affect the query. The sort is definitely not what I expected.
In advance, thank you for your help and expertise.
Here is the OneDrive link: https://onedrive.live.com/redir?resid=B220B890CEE8154E!501&authkey=!ABXydRrSRtwgtFs&ithint=file%2czip
It includes a screen clipping of the query that is ‘sorted’. The query in question is: Cons_FT_v41_Query
Here is the SQL with the sort:
SELECT Cons_FT_v4_Query.Player_ID, Cons_FT_v4_Query.Roster_ID, Cons_FT_v4_Query.Game_ID, Cons_FT_v4_Query.Skill_Level, Cons_FT_v4_Query.Full_Name, Cons_FT_v4_Query.g1_FTM, Cons_FT_v4_Query.Free_Throws_Attempted, Cons_FT_v4_Query.FT_Missed, Cons_FT_v4_Query.[Game_#], Cons_FT_v4_Query.[MaxOfGame_#], Cons_FT_v4_Query.Additional_Games, Cons_FT_v4_Query.Fall_Year, Cons_FT_v4_Query.Next_Season, Cons_FT_v4_Query.g2_Season, Cons_FT_v4_Query.Next_Game, [Roster_Info]![Roster_ID] AS g2_R_ID, [Game_Stats]![Free_Throws_Made] AS g2_FTM, [Game_Stats]![Free_Throws_Attempted] AS g2_FTA, Val(Nz([g2_FTA],”0″))-[g2_FTM] AS g2_Ms, IIf([g2_Ms]=0,[g2_FTM]+[g1_FTM],[g1_FTM]) AS g2_C_FT
FROM (Cons_FT_v4_Query INNER JOIN Roster_Info ON (Cons_FT_v4_Query.g2_Season = Roster_Info.Season_Play) AND (Cons_FT_v4_Query.Player_ID = Roster_Info.Player_ID)) INNER JOIN Game_Stats ON (Cons_FT_v4_Query.Next_Game = Game_Stats.Game_ID) AND (Roster_Info.Roster_ID = Game_Stats.Roster_ID)
ORDER BY IIf([g2_Ms]=0,[g2_FTM]+[g1_FTM],[g1_FTM]) DESC; -
WSruirib
AskWoody LoungerJanuary 11, 2016 at 9:48 am #1546681The problem is that you ordering by aliased column names, which Access doesn’t like.
The issue has an easy solution, though: Use the original query as a subquery, which means that all the aliases used will be actual column names, so the problem will go away.
Here is the SQL:
Code:SELECT Cons_FT_v41_Query.*, IIf([g2_Ms]=0,[g2_FTM]+[g1_FTM],[g1_FTM]) AS Expr1 FROM Cons_FT_v41_Query ORDER BY IIf([g2_Ms]=0,[g2_FTM]+[g1_FTM],[g1_FTM]) DESC;
-
WSjlwood44
AskWoody LoungerJanuary 12, 2016 at 10:41 am #1546875I tried using your code, and ran into a couple of problems. (1) both [g1_FTM] and [g2_FTM] are listed in the query as FTM.
(2) now I am getting parameters for both [g2_Ms] and [g2_FTM], so my/our iif statement is not running row by row, and everybody’s first game of free throws made is having the parameter value added to it. -
WSruirib
AskWoody LoungerJanuary 12, 2016 at 11:30 am #1546894I tried using your code, and ran into a couple of problems. (1) both [g1_FTM] and [g2_FTM] are listed in the query as FTM.
(2) now I am getting parameters for both [g2_Ms] and [g2_FTM], so my/our iif statement is not running row by row, and everybody’s first game of free throws made is having the parameter value added to it.You need to remove the column added to Order by in Cons_FT_v41_Query. Just delete the whole column and save the query. Once you do that, the query based on the code I posted before will run without issues.
I have attached a copy of the database with a new Query, named FixedQuery, that solves the problem. Of course, Cons_FT_v41_Query has been changed as I described.
-
-
-
WSjlwood44
AskWoody LoungerJanuary 16, 2016 at 6:31 pm #1547647Thank you very much for the help.
2 adjustments that I made: (a) instead of Expr1, I used my name ‘cons_FT_2g’ and (b) ORDER by ‘cons_FT_2g’.
Again thank you very much for your help, effort and expertise, AND taking the time to write the solution that I could easily use and understand. -
WSruirib
AskWoody Lounger
Viewing 6 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Frustrating search behavior with Outlook
by
MrJimPhelps
2 hours ago -
June 2025 Office non-Security Updates
by
PKCano
5 hours, 13 minutes ago -
Secure Boot Update Fails after KB5058405 Installed
by
SteveIT
34 minutes ago -
Firefox Red Panda Fun Stuff
by
Lars220
5 hours, 9 minutes ago -
How start headers and page numbers on page 3?
by
Davidhs
15 hours, 33 minutes ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
10 hours, 9 minutes ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
1 day ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
1 day ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
13 hours, 57 minutes ago -
Firefox 139
by
Charlie
6 hours, 32 minutes ago -
Who knows what?
by
Will Fastie
1 hour, 5 minutes ago -
My top ten underappreciated features in Office
by
Peter Deegan
1 day ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
19 hours, 23 minutes ago -
Misbehaving devices
by
Susan Bradley
7 minutes ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
2 days, 6 hours ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
4 hours, 16 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
2 days, 5 hours ago -
Discover the Best AI Tools for Everything
by
Alex5723
1 day, 4 hours ago -
Edge Seems To Be Gaining Weight
by
bbearren
1 day, 19 hours ago -
Rufus is available from the MSFT Store
by
PL1
2 days, 3 hours ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
3 days, 6 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
1 day, 6 hours ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
1 day, 5 hours ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
3 days, 2 hours ago -
Office gets current release
by
Susan Bradley
3 days, 5 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
4 days, 19 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
4 days, 3 hours ago -
Stop the OneDrive defaults
by
CWBillow
4 days, 19 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
5 days, 5 hours ago -
X Suspends Encrypted DMs
by
Alex5723
5 days, 8 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.