Question

Alphabetical Recordset Navigation/Index

Asked by: Corrupticus

I have an dreaweaver-built ASP page that displays the results of an access DB via the recordset derived from a DB query. My asp page has buttons that sort (via URL params) the Access DB results by column name - using order by ASC or DESC. I page through the recordset at 15 records per page.

They way the numeric paging works now is that when the next/previous page is clicked on there's a variable called offset that gets appended to the URL that changes with the page #. For instance, when the page first loads (page 1) the offset is 0. For the next page (page 2) with the next set of records, the offset is 15, the next page offset is 30 (in line with the 15 results per page setup) and so forth.

When a user sorts the results of the DB by the column "company", for instance, they have keep paging thru the recordset to get to a company beginning with a certain letter. Even though the results can be sorted ASC or DESC, a user still has to keep flipping thru the pages to get to a company whose name begins with say letter "J". What I'd like to do is create an alphabetical index at the bottom of the ASP page, underneath the numeric page numbers, that allows users to click on a given letter (e.g. "J") and have them taken to the section of the recordset with companies that begin with letter "J"

This way I I have the offset/page jumping to wherever wherever it is in the recordset that the company starts with "J" or whatever letter has been clicked on. The offset for letter "J" is offset 201 (page 14) - which displays the results for companies that begin with J and whatever else follows in the recordset. The user can then keep paging thru the recordset numerically (using the pages) if they choose to, to see the next set of records - any left-over Js & K's and beyond.

Hardcoding the offsets to the letters would not be very feasible in the long-run b/c if new records are added, the offsets will surely change, and will no longer be accurate. Is there any way to programmatically assign a letter to an offset/page #, such that when the letter is clicked on, the user can "jump" to the section of the recordset where the records begin with the clicked on letter?

Any assistance with this (esp with examples) will greatly be appreciated!

I've included the numeric paging code (a dreamweaver extension by tom muck) which might be useful in helping to see how the paging (and use of offset) works:

VARIABLES USED IN THE CODE:
MM_Size = rsProposals_numRows
rsProposals_numRows = rsProposals_numRows + Repeat1_numRows
Repeat1_numRows = 15  'i.e. 15 records per page

MM_keepMove basically keeps track of what URL parameters are to be maintained - in this case the DB column to be sorted by and the direction of sort - ASC or DESC

Note: 9 pages are displayed at a go - i.e. one can choose to view/browse the results of up to 9 pages at a go

'This section shows/navigates back to the Previous 9 pages
<%
If MM_offset > MM_size * 9 Or MM_offset/MM_size - int(9/2) > 0 Then
    TFM_Previous = MM_offset - 10 * MM_size
   If TFM_Previous < 0 then TFM_Previous = 0  
    Response.Write(".<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & TFM_Previous & """>")
   Response.Write("Previous " & "9" & " pages</a> ")
End If
%>

''This section shows the current 9 pages a viewer can click on to view results for : i.e. e.g. -> 10 11 12 13 14 15 16 17 18
<%
TFM_MiddlePages = 9  ' # of pages to be displayed at a time
TFM_delimiter = " "    ' a space separates the page #s
TFM_startLink = MM_offset + 1 - MM_size * (int(TFM_middlePages/2))
If MM_offset > 0 Then TFM_LimitPageEndCount = int(TFM_startLink/MM_size)
If TFM_startLink < 1 Then
     TFM_startLink = 1
    TFM_LimitPageEndCount = 0
End If
TFM_endLink = MM_size * TFM_MiddlePages + TFM_startLink - 1
If TFM_endLink > rsProposals_total Then TFM_endLink = rsProposals_total
For i = TFM_startLink to TFM_endLink Step MM_size
 TFM_LimitPageEndCount = TFM_LimitPageEndCount + 1
 if i <> MM_offset + 1 Then
   Response.Write("<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & i-1 & """>")
   Response.Write(TFM_LimitPageEndCount & "</a>")
 else
   Response.Write("<font color='#FF0000'> ")  ' change color of currently displayed page (which is now unclickable)
    Response.Write(TFM_LimitPageEndCount & "</font> ")
 End if
 if(i <= TFM_endLink - MM_size) then Response.Write(TFM_delimiter)
Next
%>

'This section shows/navigates to the Next 9 pages
<%
If MM_offset < rsProposals_total - MM_size * 9 Then
    Response.Write(" <a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & (MM_offset + 9*MM_size) & """>")
   Response.Write("Next " & "9" & " of " & rsProposals_TFMtotalPages & " pages</a> ")
End If
%>

The actual paging text displayed on the ASP page looks something like:

 1 2 3 4 5 6 7 8 9   Next 9 of 26 pages  ' for offset = 0 -> 1 is colored red (#FF0000) and is unclickable
.Previous 9 pages   3 4 5 6 7 8 9 10 11   Next 9 of 26 pages  ' for offset = 90 -> 7 is colored red and unclickable now
.Previous 9 pages   21 22 23 24 25 26   ' for offset = 375 - the last of the records in the recordset -> 26 is red & unclickable

Hope this helps!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-08-05 at 10:39:40ID20700487
Tags

letters

,

navigation

,

recordset

Topic

Adobe Dreamweaver

Participating Experts
3
Points
0
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Recordsets
    I have a recordset and the following fields, Date, start time, end time for some activities, I need a code to draw a graphical representation of a day calendar to show the available free hours within the perion e.g 8am - 5 pm, bu painting a different colour for each activity....
  2. recordsets
    I'm not really sure how a recordset works. I want to retreive the data from a database and populate text boxes with the fields from the recordset. This I have been able to do. If the user changes anything and clicks update I want the recordset to update the information. I'...
  3. Recordsets not recognized
    I am constantly having problems with Dreamweaver not recognizing recordsets that I have created. I create recordsets using the Bindings tab and they Test fine and show up in the Bindings window. However, when I try to create a Server Behavior (using the Plus sign in the Se...
  4. Recordset Navigation Bar & Status Question - Dreamwea…
    Can anyone tell me why in my Recordset Navigation Status bar, where it says RECORD 1 OF 11 (... by using RECORD rsLAST OF rsTOTAL) the "rsLAST" for me never changes but stays at "1", even when i inserted it from Dreamweaver and NEVER edited the code? IN...
  5. Recordset Paging In Dreamweaver.
    I have a page pulling data from an access DB using a recordset. I want to list the repeated regions here but want to limit the page to 5 records. I need a Previous | Next bar at the bottom. I am using the server behavior panel and adding the recordsetpaging>move to nex...
  6. Recordset
    Hello Experts I want to create a recordset in dreamweaver If I create and advanced recordset Connection xxx SELECT * from Products it tests OK If I try to create a simple recordset a message appears Unable to retrieve tables from this connection click on define etc When...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: CorrupticusPosted on 2003-08-05 at 10:40:21ID: 9082279

MORE EXAMPLES:

mypage.asp?offset=0   - displays initial set of 15 records according to the alphabetic sort order  (page 1)
mypage.asp?offset=15 - next 15 records  (page 2)
mypage.asp?offset=30 - next 15  (page 3)
mypage.asp?offset=45 - etc  (page 4)

From page 4, one can go (by typing in or clicking on the page links) to mypage.asp?offset=201 (page 14) which shows the results for companies beginning with the letter J. One can then hit the back button on the browser to take them back to page 4 (offset=45) and keep sequentially paging thru the recordset to page 5 (mypage.asp?offset=60)

or keep going forward from page 14 (offset 201) to page 15 (offset=216) and beyond.

This is the sort of flexibility I'm looking to have, by dynamically (not hardcoding) assigning letters to page #s (offset#s)

 

by: CorrupticusPosted on 2003-08-05 at 13:35:39ID: 9083583

if I use a WHERE clause in my select statement, only the records beginning with the chosen letter will be displayed... The user should be able to keep paging thru (both fwd and backward) the entire universe of records after jumping to records beginning with a particular letter in the recordset. For instance, after jumping to letter "J" the user should be able to click on the next/previous page # to see the records K and beyond - or I and before.... Using a WHERE clause in the SQL precludes this...

 

by: kanaryPosted on 2003-08-06 at 03:11:22ID: 9088811

hello Corrupticus,
first of all, very long questions with less points doesn't encourage experts to read and solve ur problem.

second:
through my whole years of experience in web surfing and development, i have never such an idea.

using offsets for paging is nice, and also static that will not be changes.except u decided to change no of results per page.

but as a concept. if there were an alphabetical index in any page, that means a small query that searches all records in the database that starts  "only" with this alphabet.

u can make a survey for people around u and ur friends, ask them if u found this alphabetical index, what will it indecate.

1) just all records starting with this alphabet
2) all records starting with this alphabet and alphabets larger than it.

and let me know

 

by: CorrupticusPosted on 2003-08-06 at 08:19:41ID: 9091902

To encourage experts to participate, I'm doubling the points...

Kanary, the answer to your question would be a modified 2) - i.e. Index should allow the display of all records starting with the given letter and alphabets larger (if you hit the next page link) or smaller (if you hit the previous page link) than it. I basically need a way to find out what the offset is for the first record that begins with the given letter - this way, from this offset, a user can page both front and back as needed.

My aim is to:
1) Find the first record(s) begining with the clicked on letter
2) Get the offset for that record
3) Assign that offset to the respective letter

I'm trying to achieve 1) using a regular expression, but  it's not quite working though because I'm not very good at using regular expressions.

Here is my code so far...

VARIABLES USED
rsProposals is the recordset

<%
delimiter = " "
Dim recSetCol, urlString, results
recSetCol = rsProposals("company")  'the column in the recordset that I am looking for a particular letter in

    function findRecords(ltr,rSetCol)
         dim re,matches,letter
         
         letter = ltr          
         set re = new RegExp
         re.pattern = "^"&letter&".*?"   ' I'm trying to look for the beginning of the company name starting with the letter in question
         re.IgnoreCase = True
         set matches = re.execute(rSetCol)
         if matches.count then
              findRecords = matches(0)   I need help using this - I'm trying to print out the results of the match - this shows 1st letter only
         else
              findRecords = ""
         end if
         end function

For i = 65 to 90  ' prints A-Z - the letters that a user can click on to see the company names begining with that letter clicked on
  TFM_character = Chr(i)
 
   results = findRecords(TFM_character, recSetCol)
   Response.Write("<font color='#FF0000'> ")
   Response.Write(results & "</font> ")  'trying to see what my regexp did - it actually prints out the first letter corresponding to the recordset results on the current page - i.e. prints out D, if the records on page are D records (there are some C records however), E if the next page shows E records (although there are some D records) - so it at least works somewhat....
 

   Response.Write("<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "page_num=" ) 'this would be where the user would go if they click on say J, - to the page where the company name begins with J
  Response.Write(""">" + TFM_character + "</a>")
  If(i<90)Then Response.Write(delimiter)
Next
%>

 

by: kanaryPosted on 2003-08-07 at 04:15:29ID: 9098602

hello Corrupticus  again,

i have thinked in ur problem well, im going to provide a soluition to ur problem but bot the code, if u have any problems with the code i think u should ask in the asp forum, ok.

here's the scenario:

1) define no of results per page at first, let's say: pagesize=20
2) now u search the database, let's say the result were 1000 records reurned.
 suppose u were searching for certain companies, the search result returns company specifications and locations, let the search result return company IDs also.
now u have the company ID's that have been returned from the search, and these companies are the one who should be indexed by it's first Alphabet.
3) create an array of integers and store all the company IDs into it, and store this array into session array.
now this session array will be in ur hand while browsing next or previous as u wish.
4) create another session variable telling u the page number u r in, say: pageno=1

when the pageno = 1 u list the first 20 records (0 -> 20*1) from the Company ID's array
when pageno = 2 u list the next  20 records (20*1 -> 20*2) which is (pagesize* pageno) and so on.

using this way, add as many records as u wish,  change no of result per page as u wish, u won't have to store a certain offset value per each page at all.

also this will solve ur problem, how?

now u wana index the result alphabetically, suppose u clicked the alphabet "C". now u will search the result array for the first occurance of the "C". as long as we have 1000 company IDs resulted from the search, suppose that the first occurance of the "C" is at record no  105 from the 1000.
using calculations u will get that if the page size is 20, so we will have to press next 5 times to get to index 105.
and the page no will be no 6 pageno=6.

pageno=Mod(1000/105)

 

by: kanaryPosted on 2003-08-07 at 04:20:41ID: 9098627

sorry, delete the last line.

page no = 105/20   = 5.25

that means the page after pafe 5 , yet to page 6

so will return the same result if u were not searching for a certain alphabet, except for that u will display  page 6 at first, that means u have searched the result according to the charachter selected and the next and previous navigation are as normal as the ordinary search.

what do u think

 

by: kanaryPosted on 2003-08-07 at 04:21:20ID: 9098633

don't u think this idea worth 500 points :))

 

by: phillystyle123Posted on 2003-08-08 at 20:32:38ID: 9112691

why not completely do away with this search step and just use a dynamic drop down list on the search form page?  this way the user can just type in or choose the company and not have to deal with paging through to get what they want.

 

by: kanaryPosted on 2003-09-06 at 11:23:58ID: 9302126

hello Corrupticus,

i have given u an excellent solution to ur problem.
so i think u should reward the points and end the question by now.
waiting ur action here.

thx a lot.

 

by: CorrupticusPosted on 2003-09-08 at 09:10:37ID: 9310333

Kanary, first of all, I don't know why you assume that you gave me an "excellent solution" that you think is worth 500 points. I don't understand how you arrived at this conclusion. To cut to the chase and make the long story short, I'll reiterate, from my previous comments above, what I was looking for:

comment 1:

-> Is there any way to programmatically assign a letter to an offset/page #, such that when the letter is clicked on, the user can "jump" to the section of the recordset where the records begin with the clicked on letter?

-> Any assistance with this (esp with examples) will greatly be appreciated!

-> I've included the numeric paging code (a dreamweaver extension by tom muck) which might be useful in helping to see how the paging (and use of offset) works


If u read my comments and take a closer look at the code I provided, you will realize I already have in place a navigation scheme that defines, calculates and displays the number of records per page - 15 records per page. Which means I always know what page I'm on - even if I manually change the offset parameter (which gets translated to a page number by the code).  I would also have know what the total # of records returned is (which is how the total number of pages is determined) Hence - I don't need to go thru steps 1 & 2 of your 'solution' or redundantly use session arrays as you suggested in points 3 & 4 of your comment. Why create a superfluous array to search thru, when I can search thru my recordset??

Again, from my comments above:

My aim is to:
1) Find the first record(s) begining with the clicked on letter
2) Get the offset for that record
3) Assign that offset to the respective letter

I have figured out how to find the first record  beginning with whatever letter is clicked on. What's left is finding out what offset/page number the record is on and dynamically assign that offset to the respective letter each time the page loads - such that when the user clicks on that letter, they are taken straight to the respective page. If you or anyone else can help me find a way to do this, (and not ask that I go to the asp forum for help with code - why reward the same question twice in different forums) then we can start talking points. Till then, feel free to share any meaningful ideas you may have - thanks!


 

by: kanaryPosted on 2003-09-08 at 12:19:47ID: 9311446

hello again,
i won't be able to help as im too bust these days.

u can ask a new question inasp withoit doubling the points.
open a new questio in asp and paste the url of this forum,
if u find an answer there u can ask the administrators to delete this question

wishing u good luck.
kanary.

 

by: CetusMODPosted on 2004-03-24 at 10:10:50ID: 10670052

PAQed, with points refunded (200)

CetusMOD
Community Support Moderator

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...