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.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
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, 5 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
-
Windows 11 blocks Chrome 137.0.7151.68, 137.0.7151.69
by
Alex5723
3 hours, 26 minutes ago -
Are Macs immune?
by
Susan Bradley
50 minutes ago -
HP Envy and the Function keys
by
CWBillow
6 hours, 32 minutes ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
14 hours, 43 minutes ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
15 hours ago -
Unable to update to version 22h2
by
04om
1 hour, 43 minutes ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
22 hours, 28 minutes ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
22 hours, 31 minutes ago -
Very Quarrelsome Taskbar!
by
CWBillow
8 hours, 21 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
1 day, 11 hours ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
1 day ago -
Is your battery draining?
by
Susan Bradley
5 hours, 13 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
3 hours ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
1 day, 15 hours ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
23 hours, 24 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
23 hours, 37 minutes ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
16 hours, 16 minutes ago -
National scam day
by
Susan Bradley
23 hours, 9 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
19 hours, 18 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
2 days, 16 hours ago -
Tools to support internet discussions
by
Kathy Stevens
1 day, 5 hours ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
2 days, 7 hours ago -
AI is good sometimes
by
Susan Bradley
2 days, 23 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
2 days, 13 hours ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
3 days, 23 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
3 days, 22 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
4 days, 2 hours ago -
Excessive security alerts
by
WSSebastian42
2 days, 17 hours ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
4 days, 11 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
16 minutes 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.