Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Keep focus on current record after code (2000 (all updates))

    On a form, I have customized navigation buttons, plus a text box that keeps track of the records and shows "Record x of y", and if on a new record the text box shows "New Record"

    On a form, I have a "Save Record" command button. In order to have the text box reflect the correct number of records after Save, I have the following code...

    If Me.RecordsetClone.Restartable Then
    Me.RecordsetClone.Requery
    End If

    However, since this updates the recordset, the focus jumps to the first record in the set.

    In order to get the focus to shift to the last record in the set, I can modify the code as...
    If Me.RecordsetClone.Restartable Then
    Me.RecordsetClone.Requery
    DoCmd.GoToRecord , , acLast
    End If

    And this works fine, providing that the record being saved was a new record.

    However, suppose that the record being saved was not a new record, but rather an existing record being edited. Is there a way to put the focus back on the record being edited, following the recordset update, in order for the user to see the changes reflected?

    I have tried...
    DoCmd.GoToRecord acDataForm, "frmSaturdaySupper", acGoTo, CurrentRecord
    but that doesn't make any difference.

    Thanks.

    Tom

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keep focus on current record after code (2000 (all updates))

    Why go to all this trouble if the built-in navigation buttons keep track of the correct number of records automatically, without any code at all?
    Why do you need a Save Record button? Access will save a record automatically.

    In your code, you only need to requery if you saved a new record, so you can test

    If Me.NewRecord Then
    ...
    End If

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep focus on current record after code (2000 (all updates))

    Hans
    Your observations and questions are good. However...

    re Navigation buttons...
    The database is for a volunteer group. The user has a moderate vision impairment, and wanted navigation buttons that were larger and more specific than the built-in butons.

    re Save button...2 reasons...
    1. There is a list box that keeps track of monthly totals from records that are input. The user wanted to see immediate update in the list box. The simplest, it seemed to me, was to add a Save button.
    2. The user also requested a Save button - provides some security, I gather, to have to so something to see that a record was being saved.

    As for your suggestion of adding the "If New Record..." to the code, I don't know why I didn't think of that. A matter of "the forest and the trees," I guess.

    Thanks, Hans.

    Tom

Posting Permissions

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