Mark a Record on a Form and Return to It Later
Problem
Sometimes you are interrupted when you’re editing a record on a form and need to move quickly to some other record. You’d like a way to save your place and easily return to it later. Is there an easy way to do this in Access?
Solution
Access forms have a Bookmark property that is similar to the bookmark you use when you put a book down but want to be able to quickly return to where you left off. This solution shows how to use VBA code to store the bookmark value of a particular record and return to it, presenting this functionality to your users with a toggle button. The solution also shows you how to add a custom shortcut menu to a control.
Follow these steps to add the ability to return to a designated record in your own forms:
Create a new bound form or open an existing form in design view. Add a toggle button (not a command button) control to the form’s header or footer section. In the frmCustomer sample form, we named our button tglMark and added it to the header section.
Create an event procedure attached to the Click event of the toggle button. (If you’re unsure of how to do this, see Section P.5.5 in the the preface of this book.) Add the following code to the event procedure:
Private Sub tglMark_Click( ) ' If the toggle button is depressed, mark this record; ' otherwise, return to the previously saved record. If Me!tglMark Then Call acbHandleMarkReturn(conMark) Else Call acbHandleMarkReturn(conReturn) End If End ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.