Go Back   Access World Forums > Microsoft Access Discussion > Forms

Thread Tools Rate Thread Display Modes
Old 08-14-2019, 02:51 AM   #1
Enthusiastic Amateur
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,850
Thanks: 411
Thanked 691 Times in 670 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about Gasman has a spectacular aura about
When is a Bookmark created ?

Hi all,
Not played around with bookmarks much, but wanted to use it to get back to a record after a requery on the form.

My code for the Requery button is

Private Sub cmdRequery_Click()
    Dim lngId As Long
    Dim rst As DAO.Recordset
    Dim strCriteria As String
    Dim varBookMark As Variant
    ' Save record so requery on subform will pick up all last record written
    If Me.Dirty Then Me.Dirty = False
    lngId = Me.ID
    varBookMark = Me.Bookmark
    strCriteria = "ID=" & lngId
    'Set rst = Me.sfrmEmails.Form.Recordset

    ' Requery the subform
    ' Go back to record we were on
    Me.Recordset.FindFirst strCriteria
    ' Now the sub form
    'rst.FindFirst strCriteria
    'Set rst = Nothing
    'DoCmd.RunCommand acCmdRecordsGoToLast
    DoCmd.RunCommand acCmdRecordsGoToLast
    DoCmd.GoToRecord acDataForm, Me.Name, acPrevious, 5 ' Needed for a continuous form as only last record shows.
    'DoCmd.RunCommand acCmdRecordsGoToLast
    Me.Bookmark = varBookMark

End Sub
I had just added a new record and then pressed the Requery button. The code works fine if I have not added a record. This is the first time I have added a record since amending the code.?

I expected the Me.Dirty to save the record, but both Me.BookMark and varBookMark have ? when printed in the immediate window?

What do I need to check for when having added new record(s) please?

The error is 3159 Not a valid bookmark, which I accept a ? would not be.


Access novice. Sometimes trying to give something back.
Access 2007

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 08-14-2019, 02:57 AM   #2
Newly Registered User
Join Date: May 2018
Location: USA baby
Posts: 1,683
Thanks: 27
Thanked 510 Times in 483 Posts
MajP will become famous soon enough MajP will become famous soon enough
Re: When is a Bookmark created ?

 varBookMark = Me.Bookmark
as soon as you requery you get a new set of bookmarks. Code fails here.

MajP is offline   Reply With Quote
The Following User Says Thank You to MajP For This Useful Post:
Gasman (08-14-2019)

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bookmark kirkm General 4 07-03-2019 04:51 AM
me.bookmark the_net_2.0 Modules & VBA 4 12-26-2010 05:55 AM
Not a valid bookmark farrio VB.NET 0 01-21-2008 09:33 PM
Bookmark for recordsets object not co-ordinating with bookmark of the form AshikHusein Modules & VBA 3 08-19-2004 07:35 AM
[SOLVED] bookmark amin islam General 0 07-22-2003 07:41 AM

All times are GMT -8. The time now is 12:58 AM.

Microsoft Access Help
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post

Sponsored Links

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World