Results 1 to 4 of 4
  1. #1
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159

    .Bookmark property invalid

    I have encountered an odd situation where the bookmark property doesn't seem to want to behave.



    It is important that my user be able to .Requery her subdatasheet and not end up losing her place. No problem:

    Code:
        Dim strBookmark As String
        strBookmark = Me.subOrders.Form.Bookmark
        Me.subOrders.Form.Requery 
        Me.subOrders.Form.Bookmark = strBookmark
    and it works - most of the time. Oddly, if you put on a filter of any kind in the Subdatasheet and ran just these 4 lines on a button_click event, you'll get an Invalid Bookmark error. Close the error dialog and try again - everything works just fine. Now toggle the filter off and you'll get the Invalid Bookmark error dialog again. Close it and everything works fine.

    Seems like the first Requery after you apply a filter invalidates a previously stored bookmark... at least in this DB, I cannot reproduce it elsewhere.

    Have a look if you want. The only button/code you need concern yourself with is the one captioned "Command117", and the Datasheet subform right above it. The "order manager" Form where all this is happening should open automatically.

    I've got a workaround, but I feel like I need closure as to why this is happening.
    Attached Files Attached Files

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    See if this does what you want and then we can talk. BTW, did you know that a Bookmark is not a String?
    Attached Files Attached Files

  3. #3
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    159
    Thank you RuralGuy, this is the same workaround I finally settled on, only yours is better written.

    You mentioned that .Bookmark is not a string, and I have been wondering about this for a while:
    The help file for Recordset.Bookmark(https://msdn.microsoft.com/en-us/lib.../ff823084.aspx ) says "To create a bookmark for a record other than the current record, move to the desired record and assign the value of the Bookmark property to a String variable that identifies the record. (bold letters theirs)" But the help file for the Form.Bookmark identifies itself as a "Read/Write Variant".

    #1) What's the Difference Between Form.Bookmark and Form.Recordset.Bookmark?

    #2) Along the same vein in this example, what's the difference between Me.Subformname.Requery, Me.Subformname.Form.Requery, and Me.Subformname.Form.Recordset.Requery?

    #3) I'll digress and say I hate the "Variant" datatype . Even after reading the MSDN file on them, which tells you "what it is" - how/why I would wisely use it in practice, I don't understand. Why not just disambiguate your variables and write, Long, String, Recordset, etc. When would a programmer NOT know his variables intended use in advance? If you know a good primer on this, I'm all ears.

    Thank you for any insight.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You are correct about the ambiguity of that msdn link. I've always used a Variant datatype but Access is good at coercing a variable to what you need. As for all of the different versions of the syntax that is Access in the background helping again. I would stick with the Me.Subformname.Form.Recordset.Requery syntax incase ms decides to deprecate the other versions. I would say that any time you requery a recordset the bookmark can become invalid which is why I chose the [ID] which will not change unless you filter that record out. 8^) Have a good one.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-09-2015, 11:26 AM
  2. Replies: 1
    Last Post: 04-10-2015, 07:40 AM
  3. Invalid reference to the parent property
    By Access_Novice in forum Programming
    Replies: 1
    Last Post: 12-28-2013, 05:17 PM
  4. Compile Error: Invalid user of property
    By jwill in forum Programming
    Replies: 16
    Last Post: 11-20-2012, 05:23 PM
  5. Replies: 7
    Last Post: 08-28-2011, 02:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums