Re: Continuous Form and Query
- From: "Wes H." <wphenry@xxxxxxxxx>
- Date: Thu, 18 May 2006 11:59:28 -0500
Oh, I see. That makes more sense than the way I was reading it. Unfortunately I can't get this to work. I set my query up to look like this in sql:
SELECT DISTINCTROW tbl_main.Home_Name, Sum(tbl_main.Home_Points) AS [Sum Of Home_Points], (SELECT Count(*) FROM tbl_main AS MyTable1 WHERE [home_points] <[tbl_main].[home_points]-1) AS Rank
FROM tbl_main
GROUP BY tbl_main.Home_Name;
I've tried a couple of different things but not sure what exactly it is that I am missing that is keeping this from working. Any ideas? Thanks again for the help Barry.
Wes
Barry Gilbert wrote:
Not exactly. This isn't procedural code. This statement is evaluated for each record of your table. As each record is evaluated, it looks at all records in the same table and finds the number of records where the UnitsSold value is less than the UnitsSold value in the current record..
Barry
"Wes H." wrote:
Thanks for the help Barry. So, let me make sure I understand. If I am reading this right, which I hope I am, then it counts the records in the table and lets say it equals 35. Then it starts at the end and starts numbering backwards, but it seems like each column would have the same number, or am I reading this wrong? Thanks again for the help Barry.
Wes
Barry Gilbert wrote:Let's assume the column you want to rank by is called UnitsSold. In your query, add a column called Rank. It will look like this:
Rank: (SELECT Count(*) FROM tblMyTable AS MyTable1 WHERE [UnitsSold] < [MyTable].[UnitsSold]-1)
HTH,
Barry
"Wes H." wrote:
I realize that. But once it is sorted and being displayed on the form I want to be able to look and see that dallas is ranked 3rd, or denver is ranked 17th, etc. without having to count line by line each time i want to figure out what rank a team is in. That's the reason for the numbers, not for sorting.
Barry Gilbert wrote:I'm not sure why you'd need the extra column. You could simply set your query to sort by the value in descending order.
HTH,
Barry
"Wes H." wrote:
I have a query that is summing up numbers. This query is then being accessed in a continuous form so that it looks something like this:
Denver 496
Dallas 451
St. Louis 399
Arizona 251
Since this info is constantly changing, what I am looking for is a way of having each of these items to be numbered respectively from top to bottom, so that it looks something like this:
1 Denver 496
2 Dallas 451
3 St. Louis 399
4 Arizona 251
And that way when it changes the respectable ranking number is also changed to be something like this:
1 St. Louis 821
2 Arizona 733
3 Denver 601
4 Dallas 455
Not sure if this can even be done and if so then can it be done via the query or the form or vba, but any info on how I can do this would be greatly appreciated. Thanks for the help in advance.
- Follow-Ups:
- Re: Continuous Form and Query
- From: Barry Gilbert
- Re: Continuous Form and Query
- References:
- Continuous Form and Query
- From: Wes H.
- Re: Continuous Form and Query
- From: Wes H.
- Re: Continuous Form and Query
- From: Wes H.
- Re: Continuous Form and Query
- From: Barry Gilbert
- Continuous Form and Query
- Prev by Date: Autocomplete not working in Access combo box
- Next by Date: RE: I give up!!!!!!!!!!!!
- Previous by thread: Re: Continuous Form and Query
- Next by thread: Re: Continuous Form and Query
- Index(es):
Relevant Pages
|