Results 1 to 4 of 4
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    stay on specific record of continuous form after saving

    I have a continuous subforum whereby I would like to stay on the current record after making a change and not have the focus go to the top record in the listing after the change.



    Hopefully that makes sense. Stating the right question is key to the right answer. Not exactly easy sometimes. Thanks.

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Assume you are refreshing the form after the change?
    There as usual a number of ways to achieve this depending on the circumstances.

    Normally the easiest way is to requery the forms recordset - not the form itself, that should leave you on the same record.

    Maybe post up what code you have that is refreshing/requerying the form?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not sure, but requery of recordset would reload and make the first record current, but refresh would not? The answer to the problem may depend on what the "changes" are. If it's editing existing then maybe refresh would do the job but the form cycle property may need to be set to 'current record'. If it's about deleting or adding records, that won't do it - you'd need to bookmark the current record, requery the form and then make the current record that of the bookmark. I can't recall if the bookmark for the current record will still be valid after records are added or deleted (sucks getting old but it's better than the alternative). If not, you could get the record id instead and go to it after then append/delete operation.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    So, I resolved my issue. I was using requery when I shouldn't have. Ended up using the following code.

    Code:
    Private Sub Form_Current()Dim lngPK As Long
            On Error Resume Next
    '       This code must come before code after the ************ to work correctly
    
    
    '       used to highlight row that is currently selected
    '       see subform OnCurrent event for Conditional Formatting
            Me.SelectedID = ID
    
    
    
    
            lngPK = Me.ID
    
    
    '       *********************************************************
    
    
    '       Remembers which record it was on before saving. Stays on current record
    '       https://www.baldyweb.com/Requery.htm
    
    
            With Me.RecordsetClone
            .FindFirst "ID=" & lngPK
            
            If .NoMatch Then
            MsgBox "Record Not Found!", vbCritical
            
            Else
            Me.Bookmark = .Bookmark
            End If
            End With
    
    
    '       sets caption for button
            Me.btnCheckboxWeight.Caption = "CK" & vbCrLf & "BX" & vbCrLf & "WT"
    End Sub

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

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2020, 01:31 PM
  2. Replies: 3
    Last Post: 06-24-2019, 11:20 AM
  3. have form stay on current record
    By JamesRocklyn in forum Forms
    Replies: 2
    Last Post: 11-20-2017, 08:20 PM
  4. Replies: 17
    Last Post: 02-28-2017, 02:12 PM
  5. Getting a continuous form to stay where it s.
    By Robbyp2001 in forum Forms
    Replies: 2
    Last Post: 10-19-2016, 07:27 AM

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