Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is the previous or the next record in a database?

Posted on 2010-11-25
4
Medium Priority
?
394 Views
Last Modified: 2012-05-10
Hi. I am using C# and MS Access database in a web site.

I filter one element and display it.

How do I know which is the previous element (to be able to make some navigation) or the next element. Also need to know if it is a first element (in this case there is no previous element) or the last element (so there is no next element.)

thx
0
Comment
Question by:kuzmar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34214154
The only way you're going to do that is to retrieve 3 records, the one you want to display, plus the one before and after, because you will need the id's from them to determine next/prev.
0
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 34215119
Unless you use an autoincrementing column. Then you can guess the previous (it may have been deleted so just keep trying smaller and smaller numbers till you get a hit)
0
 
LVL 12

Accepted Solution

by:
jagssidurala earned 2000 total points
ID: 34215181
You need to build the paging logic here like this.

For ex There 5 records are in your data.

S.No      EmployeeId      EmployeeName    TotalCount
1                    E-1                     EName1                 5
2                    E-2                     EName2                 5
3                    E-3                     EName3                 5
4                    E-4                     EName4                 5
5                    E-5                     EName5                 5

Then you can write the logic to know first or last or in the middle.

1) if PageNum = 1 this is your first record(disable prev button)
2) if PageNum <> 1 and PageNum <> 5 , this is your middle of the page(i.e 2,3,4)(enable both prev, next buttons)
3) if PageNum <> 1 and PageNum = 5 , this is your last page(disable next button)

Where 5 is your total record count.


0
 

Author Comment

by:kuzmar
ID: 34215753
totaly forgot about it... thx
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question