473,509 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add a ranking to a sorted query for comparison

4 New Member
I have an Access 2002 database of inventory count results, and I have been asked to create summaries of the items with the most losses at a store, region and national level. Individually, I have been able to create these summaries easily enough using several sorted queries and a form to select the specific store, or to pull up the regional or national summaries.

The problem is that they want to be able to have one file for each store which lists the top 30 item losses with additional fields showing where that same item ranked at the regional and national level.

One alternative I came up with was to create a new table for each of the higher level summaries (national and regional) and either use Autonumber or code to add ranking numbers. However, this is not ideal because this would require approximately 140 tables to be created to cover all of the regions.

I also tried to write a function which would be called when the user selects the store to summarize which would temporarily add the ranking to the sorted queries. However, I am getting an error that the query is not updateable. I am not sure if this is a limitation in Access, or if it is something I am doing wrong. (In a fit of frustration I deleted the code, so I can't paste it here.)

So, first question: Is it even possible to update a field for each record on a sorted query? If the answer is yes, then I will try again, and then post the code here if I continue to get an error.

THANKS!
Feb 1 '07 #1
8 3490
Rabbit
12,516 Recognized Expert Moderator MVP
I don't see where you get 140 tables.

I'm thinking 2 tables and 7 queries. Apart from your main table of course.

One table will be for regional ranking and the other will be for national. Both will have 2 fields.

tbl_National, tbl_Regional
Rank(AutoNumber) ItemID

Two queries to delete the two tables.
Two queries to recreate them.
Two append queries to get the ranking at the regional and national level.
One query to rule them all.

By which I mean join the store ranking and the other tables by ItemID.

A convoluted and UNTESTED theory. Maybe someone else can provide you with a better solution.
Feb 1 '07 #2
AnndieMac
4 New Member
Thanks for trying Rabbit, but I guess I wasn't clear enough. There are 34 different regions, and I need a ranking of items within each region, plus the national. So, that's 35 tables for one ranking system. But they also want 4 different ranking systems - loss by qty, gain by qty, loss by dollar and gain by dollar. So 35 times 4 = 140 tables (Plus 140 times 3 queries!)

I'm testing now to see if I can just have one table regardless of system, and use code to force the sort and ranking each time a store summary is selected. That would reduce my tables, but it would also slow down the database significantly, I think.
I don't see where you get 140 tables.

I'm thinking 2 tables and 7 queries. Apart from your main table of course.

One table will be for regional ranking and the other will be for national. Both will have 2 fields.

tbl_National, tbl_Regional
Rank(AutoNumber) ItemID

Two queries to delete the two tables.
Two queries to recreate them.
Two append queries to get the ranking at the regional and national level.
One query to rule them all.

By which I mean join the store ranking and the other tables by ItemID.

A convoluted and UNTESTED theory. Maybe someone else can provide you with a better solution.
Feb 1 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
And all this information is going into one report?

You can take my original idea and modify it slightly.
In the code you can have a for i = 1 to 34 loop and insert the results into another table. You end up running a lot of queries but you don't have to make as many queries.

I originally thought you only needed the ranking information for a chosen store but if you need it for every single store and every region, then i don't think there's a way around running a lot of queries. But with a loop you can cut down drastically on the amount of queries you'll need to create.
Feb 1 '07 #4
NeoPa
32,557 Recognized Expert Moderator MVP
I have an Access 2002 database of inventory count results, and I have been asked to create summaries of the items with the most losses at a store, region and national level. Individually, I have been able to create these summaries easily enough using several sorted queries and a form to select the specific store, or to pull up the regional or national summaries.

The problem is that they want to be able to have one file for each store which lists the top 30 item losses with additional fields showing where that same item ranked at the regional and national level.

One alternative I came up with was to create a new table for each of the higher level summaries (national and regional) and either use Autonumber or code to add ranking numbers. However, this is not ideal because this would require approximately 140 tables to be created to cover all of the regions.

I also tried to write a function which would be called when the user selects the store to summarize which would temporarily add the ranking to the sorted queries. However, I am getting an error that the query is not updateable. I am not sure if this is a limitation in Access, or if it is something I am doing wrong. (In a fit of frustration I deleted the code, so I can't paste it here.)

So, first question: Is it even possible to update a field for each record on a sorted query? If the answer is yes, then I will try again, and then post the code here if I continue to get an error.

THANKS!
Rabbit may not be confident in his suggestions but he's certainly on the right lines. He understands the difference between data items and data layout.
Have a look in (Normalisation and Table structures) and decide how best to store your information. It will run a lot more efficiently if it's in the one table. Above all, never let the requestors tell you how to design a database - you WILL regret it :(.
Please do come back when you've read and digested that article. I feel sure we can be more help at that stage :)
Feb 2 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Rabbit may not be confident in his suggestions but he's certainly on the right lines. He understands the difference between data items and data layout.
Have a look in (Normalisation and Table structures) and decide how best to store your information. It will run a lot more efficiently if it's in the one table. Above all, never let the requestors tell you how to design a database - you WILL regret it :(.
Please do come back when you've read and digested that article. I feel sure we can be more help at that stage :)
Well I've only been using Access for 2 months now and sometimes I feel like there may be a better solution because I don't yet know a lot of the intricacies of Access and VB.
Feb 2 '07 #6
NeoPa
32,557 Recognized Expert Moderator MVP
Rabbit, That wasn't a criticism of you. Quite the contrary!
If you've only been using Access for 2 months then I'm even more impressed :)
You've shown good understanding of the concepts so far - I thought you were far more experienced. It's our luck you visited and didn't get thrown out with the rubbish in the morning. Welcome to the party :D
Feb 4 '07 #7
AnndieMac
4 New Member
Rabbit, thanks again for your help. Just so you know, append queries didn't work because the records are not appended in the sort order, but rather in the original order on the table, so when I added my rankings, they weren't right.

NeoPa, I'm not sure what to say in regards to your post. I know I don't write like a developer; that's because I'm not one - I'm an accountant. But don't let that fool you. I DO understand the basics of good database development, and while I might not have known the terminology in the post you referenced, I did already know the concepts.

I do have a working database now, although it runs too slowly to be of much use. I will continue working on it, but I probably won't be posting here again.
Feb 7 '07 #8
NeoPa
32,557 Recognized Expert Moderator MVP
Thanks for trying Rabbit, but I guess I wasn't clear enough. There are 34 different regions, and I need a ranking of items within each region, plus the national. So, that's 35 tables for one ranking system. But they also want 4 different ranking systems - loss by qty, gain by qty, loss by dollar and gain by dollar. So 35 times 4 = 140 tables (Plus 140 times 3 queries!)

I'm testing now to see if I can just have one table regardless of system, and use code to force the sort and ranking each time a store summary is selected. That would reduce my tables, but it would also slow down the database significantly, I think.
Andie,
My intention was not to insult you or to imply lack of intelligence. I do though, find it hard to reconcile this post (#3) with your statement that you understand the concepts in the link I posted. Why would you think you needed multiple tables to hold data of a similar type? :confused:
My intentions are merely to help and guide.
Feb 7 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

12
5594
by: Irene | last post by:
Hi all again, Well, I have my Athletics database with Athletes, Competitions, Scores tables. I have a ranking query where I get back the list of the competitions-athletes and scores...
5
4036
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
1
7844
by: Joseph Bloch | last post by:
In all the threads on ranking in Access queries, I've not seen anything that deals with ranking against a subset of the query results. What I need to do is take the following query results: Dept...
5
10890
by: valglad | last post by:
Hi, The question below was posted about 4 years ago and noone was able to answer it back then. I have virtually the same type of problem so would appreciate if anyone can help. Thanks ...
6
3793
by: sara | last post by:
I hope someone can help with this. Our director wants to have a report that will have the departments (Retail stores) across the top, stores down the side and the RANKING of the YTD dept sales...
5
5071
by: Chris | last post by:
I was wodering if there was a way to rank numbers in a query like this #'s Rank 100 1 99 2 98 3 98 97 5 96 6 96
1
3131
by: OtheymAverian | last post by:
For the past few days I have been trying to figure out how to add a Ranking field to a sorted query so I can then reference the rank in a report. I am using Access 2002 and have no SQL experience,...
18
2928
by: Hunk | last post by:
Would like some advice on the fillowing I have a sorted list of items on which i require to search and retrieve the said item and also modify an item based on its identity. I think an Map stl...
10
568
by: Juha Nieminen | last post by:
Victor Bazarov wrote: If N is very large, std::set can be a real memory hog. If a more memory-efficient algorithm is needed, then a heap can be used. (The exact same type of heap as used in...
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.