473,397 Members | 1,950 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,397 software developers and data experts.

Keeping the focus on the next record when deleting a record in asubform (Access 2003)

I have a list of records in a subform that a user can either edit or
delete. This is an unbound form. If the user deletes a record, I
want to refresh the form, and then position the cursor on the next
record on that subform. This seems like that this should be a fairly
easy thing to accomplish, but I cannot get it to reposition the cursor
on the next record. The following is my code segment:

Any help would be greatly appreciated!!!

Thanks.

Stuart

----------------------------------------------
(The record source is a query that returns all the records from the
Card1 table)

Set rst = Forms![frmedit]![card1 subform].[Form].RecordsetClone

rst.Bookmark = Forms![frmedit]![card1 subform].[Form].Bookmark

RecordPos = rst.AbsolutePosition
NCID = rst![NCID]

db.Execute "Delete * from Card1 where NCID = " & "'" & NCID & "'",
dbFailOnError

'Commit the database changes
wsp.CommitTrans

Forms![frmedit]![card1 subform].[Form].Requery

rst.MoveFirst
rst.Move RecordPos, rst.Bookmark

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

Nov 19 '07 #1
1 2438
On Mon, 19 Nov 2007 14:03:25 -0800 (PST), stuart <st***********@ncmail.net>
wrote:
>I have a list of records in a subform that a user can either edit or
delete. This is an unbound form. If the user deletes a record, I
want to refresh the form, and then position the cursor on the next
record on that subform. This seems like that this should be a fairly
easy thing to accomplish, but I cannot get it to reposition the cursor
on the next record. The following is my code segment:

Any help would be greatly appreciated!!!

Thanks.

Stuart

----------------------------------------------
(The record source is a query that returns all the records from the
Card1 table)

Set rst = Forms![frmedit]![card1 subform].[Form].RecordsetClone

rst.Bookmark = Forms![frmedit]![card1 subform].[Form].Bookmark

RecordPos = rst.AbsolutePosition
NCID = rst![NCID]

db.Execute "Delete * from Card1 where NCID = " & "'" & NCID & "'",
dbFailOnError

'Commit the database changes
wsp.CommitTrans

Forms![frmedit]![card1 subform].[Form].Requery

rst.MoveFirst
rst.Move RecordPos, rst.Bookmark

----------------------------------------------------
Bookmarks are destroyed and recreated when a form or recordset is requeried and
so are useless for navigation in this scenario.

The most reliable way to move to a specific record after a form (and it's
associated RecordsetClone) is requeried, is to store the PK value or a unique
identifier from the record you wish to move to before you do the delete and
requery, and then use this value in a FindFirst call on the recordsetClone after
it has been requeried.

'get the PK of the next record
rst.MoveNext
NextPK = rst!PkField
rst.MovePrevious

NCID = rst![NCID]
db.Execute "Delete * from Card1 where NCID = " & "'" & NCID & "'",dbFailOnError

wsp.CommitTrans
Forms![frmedit]![card1 subform].[Form].Requery

rst.FindFirst "[PKField]=" & NextPK

If Not rst.NoMatch Then
Forms![frmedit]![card1 subform].[Form].Bookmark = rst.Bookmark
End If

Wayne Gillespie
Gosford NSW Australia
Nov 20 '07 #2

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

Similar topics

2
by: aaj | last post by:
Hi all I have a small but rather annoying problem with continuos forms, and am wondering if anyone can suggest a method of getting over it. The front end is Access 2002 with the BE being SQL...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
0
by: Wayne | last post by:
Can anyone cast any light on the following. I have a database that I have written in Access 2003 using 2000 file format. Everything was working OK when running it under Access 2003 but when I...
1
by: yevgenia | last post by:
Hi there, I am developing an application in Access 2003 and need to send an email through Outlook based on the information entered on the form. Everything works except that the email is being sent...
6
by: clloyd | last post by:
I have a database with over 20 tables. I need to delete one to many record(s) in all tables by using a loop code. Some tables with have one record, multiple records or no records for the criteria...
5
Dököll
by: Dököll | last post by:
Hey Fans! Perhaps you can help me... I am using MS Access 2003. I have tried a number of things to get rid of the text #Error from appearing on form fields when no data present. Tried the...
5
by: Lysander | last post by:
My collegue had to buy a new laptop that came with Office 2007 already installed. She had Access 2003 installed on top, in a different directory. None of our 2003 databases will run on her...
4
by: Queen Soso | last post by:
hi all, I have this error when I click delete link in the gridview: 'unable to cast object of type 'ASP.WebForm1_aspx' to type "system.Web.UI.WebControls.GridviewRow' I really need help as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.