473,785 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lost Bookmark

I wrote the code below to be called by a button on an open form (that has a
subform) when we need to create a new (Ghost) record using some of the
fields from the existing (current) record.

The form is based on a query that filters the form's recordset. The
environment changes rapidly so the number of "valid" records can change from
the time the form is opened to the point the recordset is requeried.

This code allows the user to add a record by pressing btnMakeGhost and if
the environment has not changed, the code returns the user to the calling
record where they can then advance one record to the New "ghost" record and
then continue on through the recordset.
However, if the environment Has changed the user gets returned to the same
ordinal record position that the calling record used to occupy (If the
original query returned 200 records and the user was on record 52 when they
pressed the btnMakeGhost they will be returned to record position 52 in the
new recordset which may now only contain 190 records placing them 9 records
ahead of the newly created record. and lost).
How can I add the record and then restart the user at the new record in the
"requeried recordset" so they finish editing that record and then continue
to go forward from there.
---------------------------------------------------

Private Sub btnMakeGhost_Cl ick()
On Error GoTo Handle_Error

Dim db As DAO.Database, tbl As Recordset
Set db = CurrentDb()
Set tbl = db.OpenRecordse t("CallTrackerM atchmakerTable" )

Dim myBookmark

myBookmark = Me.Bookmark
With tbl

.AddNew
!Call_ID = Forms![frmCallTrackerM atchMakerSelect]![Call_ID] + 0.1
!GhostFlag = "G"
'Continue populating fields......... ..

.Update
Me.Requery
Me.Bookmark = myBookmark

End With

Exit_btnMakeGho st:

tbl.Close
Exit Sub

Handle_Error:
MsgBox Err.Description
Resume Exit_btnMakeGho st

End Sub
------------------------------------------------

Thanks in advance for your help.

Len Robichaud
Feb 23 '06 #1
2 1959
Br
Len Robichaud wrote:
I wrote the code below to be called by a button on an open form (that
has a subform) when we need to create a new (Ghost) record using some
of the fields from the existing (current) record.

The form is based on a query that filters the form's recordset. The
environment changes rapidly so the number of "valid" records can
change from the time the form is opened to the point the recordset is
requeried.
This code allows the user to add a record by pressing btnMakeGhost
and if the environment has not changed, the code returns the user to
the calling record where they can then advance one record to the New
"ghost" record and then continue on through the recordset.
However, if the environment Has changed the user gets returned to the
same ordinal record position that the calling record used to occupy
(If the original query returned 200 records and the user was on
record 52 when they pressed the btnMakeGhost they will be returned to
record position 52 in the new recordset which may now only contain
190 records placing them 9 records ahead of the newly created record.
and lost).

How can I add the record and then restart the user at the new record
in the "requeried recordset" so they finish editing that record and
then continue to go forward from there.
---------------------------------------------------

Private Sub btnMakeGhost_Cl ick()
On Error GoTo Handle_Error

Dim db As DAO.Database, tbl As Recordset
Set db = CurrentDb()
Set tbl = db.OpenRecordse t("CallTrackerM atchmakerTable" )
Is there any reason that you aren't using a recordsetclone ?

eg. set tbl = Me.Recordstclon e
Dim myBookmark

myBookmark = Me.Bookmark
With tbl

.AddNew
!Call_ID = Forms![frmCallTrackerM atchMakerSelect]![Call_ID] + 0.1
!GhostFlag = "G"
'Continue populating fields......... ..

.Update
Me.Requery
As soon as you requery your bookmark is invalid.

What you'd need to do is store the primary key in a variable and then search
through your recordset to find it.
Me.Bookmark = myBookmark

End With

Exit_btnMakeGho st:

tbl.Close
Exit Sub

Handle_Error:
MsgBox Err.Description
Resume Exit_btnMakeGho st

End Sub
------------------------------------------------

Thanks in advance for your help.

Len Robichaud

Try something like this...

dim rs as DAO.Recordset, ID as long
set rs = me.recordsetclo ne
with rs
.addnew
![Field1] = Value1
NewID = ![PrimaryKeyField]
.update
end with
me.requery
set rs = me.recordsetclo ne
rs.findfirst "[ID]=" NewID
if not rs.nomatch then me.bookmark = rs.bookmark
set rs = nothing

--
regards,

Br@dley
Feb 23 '06 #2
Thank you. I searched and searched and "busted my brain" for several days
before posting. For some reason it never occurred to me that I could use
recordsetclone to add a record.

I bow to your superior experience J

Len

"> Try something like this...

dim rs as DAO.Recordset, ID as long
set rs = me.recordsetclo ne
with rs
.addnew
![Field1] = Value1
NewID = ![PrimaryKeyField]
.update
end with
me.requery
set rs = me.recordsetclo ne
rs.findfirst "[ID]=" NewID
if not rs.nomatch then me.bookmark = rs.bookmark
set rs = nothing

--
regards,

Br@dley

Feb 23 '06 #3

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

Similar topics

37
3259
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you from the path of righteousness. What about also using it as a means of exiting a procedure?
2
2588
by: Thelma Lubkin | last post by:
With Me!PERSONSLIST.Form.RecordsetClone .FindFirst strID If .NoMatch Then Debug.Print "key " & Key & " nomatch" Exit Sub Else If Me.Dirty Then Me.Dirty = False Debug.Print "A_LOAD bookmark = " & .Bookmark Debug.Print "A_LOAD cloneKey = " & .Fields("PrimKey") ' Me.Bookmark = .Bookmark
6
2043
by: Chris | last post by:
I have been learning C and want to write a program and need someone to point me in the write direction. I want to write a program to store all my webpage bookmarks in possibly one file. I want it to be a GUI. The webpage addresses will be viewed in a tree-like structure eg. Search Engines - Google - Yahoo News - BBC
1
7294
by: Reginald Bal | last post by:
Main Form/SubForm When I requery or recalc my parent form after I updated a record in my subform, I lose the focus of that particular record in my subform. Instead, the first record is selected. How can I avoid this? -- Reginald Bal
2
9500
by: Alan T | last post by:
How do I make use of the Bookmarks property so that I can write a text at/below the position of a particular bookmark or the first bookmark ? private Microsoft.Office.Interop.Word.Document myWordDoc = new Document(); myWordDoc.Bookmarks
0
1943
by: Alan T | last post by:
My code can select the content of a Word document between 2 bookmarks: if (bookmarks.Exists("first bookmark") & bookmarks.Exists("second bookmark")) { object oFirstBookmark = ("first bookmark") ; Interop.Word.Range rngBeginBookmark = _stdWordDoc.Bookmarks.get_Item(ref oFirstBookmark).Range;
4
1522
by: zzapper | last post by:
Hi, I use an internal bookmark <form method="post" action="${form_action}#mark1"> to return to the correct place in the page. In case of an error I would wish to return to the top of the screen can I overrule the bookmark "mark1" in my PHP code?
11
4283
by: Tom Clavel | last post by:
I need to make sure that I am on a different record than I just was on, in a DAO recordset. code fragment: 1. strFind = "thisSource = " & tripID & " AND thisTrip = " & tripID 2. rs.FindFirst (strFind) 3. If Not rs.NoMatch Then 4. strBookmark = rs.Bookmark 5. rs.MoveFirst
0
4076
by: JosAH | last post by:
Greetings, Introduction At this moment we have a TextProcessor, a LibraryBuilder as well as the Library itself. As you read last week a Library is capable of producing pieces of text in a simple way. We also briefly mentioned the BookMark which represents a single paragraph of text. We haven't seen it's implementation yet. This is the topic of this week's article part.
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.