Results 1 to 7 of 7
  1. #1
    jschneiter is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2020
    Posts
    10

    Get ID of previous record in a Continuous form

    I have a continuous form based on a query
    This query is sorted by a different column other than the ID



    I have a delete button on each record of this continuous form
    The Delete button works but As I do the requery, it moves the user up to the top, loosing the place they were at.

    I was thinking away around this was to get the id of the PREVIOUS record then store that. I can then use recordset clone or whatever to move back down to the record that was previous to the one I deleted.

    Does this sound like something plausible?

    Thanks in Advance!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You can move previous, store the bookmark as a string variable (I believe it's string), delete the record then FindFirst using that bookmark. However, you would have to also test that there is a previous because if they are on the first record, there isn't. There is also a way to return to the same scrollbar position but I've never used it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Hipromark is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    Bogota, Colombia
    Posts
    15
    Well, if the requery is not essential to your form, then get rid off it and do the following:

    In your macro after the DeleteRecord command, add the SaveRecord command.

    So, when the record is deleted, the cursor will go to the record located immediately after the one that was deleted.

    Let us now if this worked for you.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    but As I do the requery,
    I missed that. A requery reloads the form so of course it will jump to the first record. A refresh should not, assuming it is even needed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    jschneiter is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2020
    Posts
    10
    I figured it out and works well:

    DoCmd.GoToRecord , , acPrevious
    Me.txt_previousID = Me.txt_currentID
    DoCmd.GoToRecord , , acNext

    Because this is a continuous form, you don't even see anything happening.

    Now that I have this I am able to requery and have it set focus on the previous record. works great............except

    The fact that the record it sets focus to moves the list and scrolls till that it on top of my form.

    I wish I could just delete the record and have the continuous form not move at all. Just delete the record like in excel and keep going.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I wish I could just delete the record and have the continuous form not move at all.
    but you were told to not requery? did you try refresh as suggested? Do you really need either when you're deleting a record and going to the bookmark afterwards?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Hipromark is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    Bogota, Colombia
    Posts
    15
    I still donīt understand why do you need to requery. Also I do not understand why are you trying to create a code when you have everything already done in a simple Macro, as the one I suggested you to use.

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

Similar Threads

  1. Replies: 9
    Last Post: 01-30-2020, 10:40 PM
  2. Go to certain record on continuous form
    By LonghronJ in forum Modules
    Replies: 4
    Last Post: 05-07-2018, 12:08 PM
  3. Replies: 8
    Last Post: 02-26-2018, 05:21 AM
  4. Replies: 1
    Last Post: 04-11-2015, 10:31 AM
  5. Replies: 10
    Last Post: 10-23-2012, 12:08 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