473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Navigating Records

I have a project where I need to have navigation buttons. Now I got
them working but I found a problem that occurs when there are records
deleted from the DB. The DB I am accessing has an ID column that is
the primary key and uses AutoNumber. My program also allows the user
to delete records. My problem occurs when someone deletes a record
other than the first or last record in the DB. The way my Next
navigation button works is that it checks to see if it is on the last
record in the DB, if it is it points to the first record. If it is not
the last record then it takes the current ID and adds 1 to it and that
sends it to the next record. However let's say they are currently
viewing record #65. And let's say that somewhere in the past record
#66 was deleted. Well when they hit the next button it doesn't work
because the current record plus 1 would be 66 and that doesn't exist.
My question is that is there a way through SQL statements to tell it
to go to the next record without incrementing the ID by one so as to
avoid the error I am getting? Any help would be greatly appreciated.
Nov 12 '05 #1
1 1543
DFS
Matt,

Is there a reason you're not using the built-in navigation buttons? In my
experience, they work fine for 99.9% of situations.

In your case, you seem to be using your custom navigation buttons to do a
kind of search based on the ID value, and not on the relative position of
the record. In your custom buttons, you might try using:

DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acLast

Disregard the value of the ID you're currently on, and just move to the next
or previous record. You'll have to trap errors for being at the first and
last records (goto acFirst will throw an error if you're already on the
first record).

Or, just use the built-in navigation buttons.
"Matt" <ma******@earthlink.net> wrote in message
news:7d**************************@posting.google.c om...
I have a project where I need to have navigation buttons. Now I got
them working but I found a problem that occurs when there are records
deleted from the DB. The DB I am accessing has an ID column that is
the primary key and uses AutoNumber. My program also allows the user
to delete records. My problem occurs when someone deletes a record
other than the first or last record in the DB. The way my Next
navigation button works is that it checks to see if it is on the last
record in the DB, if it is it points to the first record. If it is not
the last record then it takes the current ID and adds 1 to it and that
sends it to the next record. However let's say they are currently
viewing record #65. And let's say that somewhere in the past record
#66 was deleted. Well when they hit the next button it doesn't work
because the current record plus 1 would be 66 and that doesn't exist.
My question is that is there a way through SQL statements to tell it
to go to the next record without incrementing the ID by one so as to
avoid the error I am getting? Any help would be greatly appreciated.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
1
by: Mary | last post by:
I want to be able to create a web form that contains textboxes, that I can nagivate thru ie:first, next , previous and last. As well as diplaying the number of records and what record I am...
3
by: Martin Williams | last post by:
This is my first post to this group. I am currently working on a project for my Intermediate vb.net class. My project is a movie rental program, which involves displaying customer records with...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
1
by: Hexman | last post by:
Hello All, What I'm trying to do is update a child record using a parent-child relation. I want to find out if it is faster than than doing multiple selects. Anyways, I've created a dataset...
0
by: Ohad Weiss | last post by:
Hi all, I've once asked about that topic. but didn't get an answer. I have a dataset based on 4 tables, which have relation between them. The main table presented to the user on textboxes...
0
by: Ohad Weiss | last post by:
Hi I have a problem with two textboxes binded to a dataset, based on paren table, and table for the child records. I can navigate between the master records (and of course the child records...
2
by: DanAusitn | last post by:
Good morning people, i have made a program which handles & manages stock. to navigate through the records i have assigned command buttons to control the data control, however in some of the catagorys...
2
tuxalot
by: tuxalot | last post by:
Strange occurrence and I've looked everywhere and can't seem to find any explanation. Using A07, when I navigate records using the built-in buttons, the text in my labels darkens increasingly while...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.