Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136

    Unanswered: Set Focus on Current Record after the After Update Command

    I have a main form with patient names. I have the form requery after update and that part works fine. How do I keep the focus on the current record? It keeps jumping me to the last record.

    I've searched and searched for this answer and can't find what I need.

    Thanks a lot!

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    When you requery, by definition you are asking Access to re-sort all the records on whatever keys you designed into the SQL statement defining the RecordSource. You will ALWAYS lose focus from the current record by requerying. The fact that you always jump to the last record is very strange, because a requery statement, in my experience, always takes the user to the FIRST record in the RecordSource.

  3. #3
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136
    I thought it strange too that it was taking me to the last record. My form is based on a query where the patient's names are alphabetized ascending.

    When the user enters a new patient, I want the patient to be placed alphabetically right away. I'm using me.requery in the After Update even for the form. Now I know from what you said that I will always lose focus from the current record by requerying.

    Is there another way to accomplish this? If not, then I'm going to take the requery out.

  4. #4
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    133
    I've done this in the past, which seems to do the trick.

    Code:
    Private Sub YourControl_AfterUpdate()
    Dim recNum As Long
    
        recNum = Me.CurrentRecord
        Me.Requery
        DoCmd.GoToRecord acDataForm, "YourForm", acGoTo, recNum
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •