How to add a "ranking" to a query (1 Viewer)

V

Vertigo

Guest
Hi guys,

Simple Question perhaps, but it has me stumped. I have a rather complex crosstab query which is used on a website (ASP) that shows a ranking for a competition. Now I need to add the rank itself, so say, just numbers from 1 to 10 which simply correspond with the row # since its ordered properly (descending by score). Sounds simple enough, but I have NO idea how to do that..

Anyone got an idea ?

Thx,
Vertigo
 
V

Vertigo

Guest
I found a way.. but it didnt quite solve my problem.

I found this: http://easyweb.easynet.co.uk/~trevor/AccFAQ/queries.htm
How can I generate a sequence of numbers (like record numbers) in a query?

n a module:

(declarations)
Option Explicit
Dim mlngCounter As Long

Function ResetCounter()
mlngCounter = 0
End Function

Function GetNextCounter(pvar As Variant) As Long
mlngCounter = mlngCounter + 1
GetNextCounter = mlngCounter
End Function


In the Query:
Select [feilds...], ResetCounter(), GetNextCounter([a valid column]) From table


So.. this works fine in Acess.. But I need to access the db through olebd in frontpage. And thats where it stops working. It gives me this error:

Server error: Unable to retrieve schema information from the record source 'WebCountryRanking' in a database using the connection string:



'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/condorcup.mdb'.



The following error message comes from the database driver software; it may appear in a different language depending on how the driver is configured.

-------------------------------------------------------

[Microsoft][ODBC Microsoft Access Driver] Undefined function 'ResetCounter' in expression.



Source: Microsoft OLE DB Provider for ODBC Drivers

Number: -2147467259 (0x80004005)

Seems like you cant execute code through oledb..

Now, does anyone have an idea ? Let me give you some more context:I’m trying to publish race results on the site dynamically from an access DB. Since I’m not much of a programmer, I’m using Frontpage with the “database results wizard” (ASP).

Assume an access query which gives me competition number, name, score,.. I can publish that with no problem, even add the correct flag and all that, but what I cant do is add this ranking column (1,2,3,4,5,..). Its not possible to hardcode this in HTML due to the way DRW works, so I tried adding it in Access, with the above trick, but that only works in Access, not through oledb.

I'm desperate here, and the clock is ticking.. anyone have an idea ?

Vertigo
 

nhtuan

New member
Local time
Today, 01:00
Joined
Dec 23, 2010
Messages
24
I find a way to return row order in query

SELECT qrytcount.bqmaso, (select count(bqmaso) from qrytcount as Count where Count.bqmaso<qrytcount.bqmaso)+1 AS [order]
FROM qrytcount
ORDER BY qrytcount.bqmaso;

Late answer! But still help,

Tuan,


:)
 

atomiden

New member
Local time
Today, 01:00
Joined
Apr 13, 2013
Messages
5
hey guys, am not much of a coding guy, but give me a formula i can type on the build of that particular ranking column in the query, i've heard the dcount function works, but i dont know how to use it. Please help asap
 

nhtuan

New member
Local time
Today, 01:00
Joined
Dec 23, 2010
Messages
24
Try to put this line in your query column and change appropriately
NUMD: DCount("*","your table name","yourIDfield <= '" & [YourIDfield] & "'")
Hope this help!
 

ahsan

New member
Local time
Today, 01:00
Joined
Sep 18, 2014
Messages
1
how to find rank in access
rank of studen
example
name marks
lezza 57
suza 76
in access query how to solve plz help.
 

Users who are viewing this thread

Top Bottom