Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-14-2019, 02:51 AM   #1
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,792
Thanks: 455
Thanked 906 Times in 870 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
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

Code:
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
    Me.Requery
    strCriteria = "ID=" & lngId
    'Set rst = Me.sfrmEmails.Form.Recordset

    ' Requery the subform
    'Me.sfrmEmails.Form.Requery
    ' 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.

TIA

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

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


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
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 2,051
Thanks: 39
Thanked 644 Times in 593 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: When is a Bookmark created ?

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

https://docs.microsoft.com/en-us/off....form.bookmark
MajP is online now   Reply With Quote
The Following User Says Thank You to MajP For This Useful Post:
Gasman (08-14-2019)
Reply

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:47 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


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