none
Move Focus to new record RRS feed

  • Question

  • I need the focus to move to the new record at the end of the sub.

    Private Sub Match_GotFocus()
        If [ADMScan] = [ADMReturned] Then
            Match = "OK"
        Else
            Match = "BAD"
        End If
        Me!TimeStamp.SetFocus          <- goes back to a TimeStamp Field instead of the next/new record
    End Sub

    How do I just move the focus to the new record?

    Monday, March 14, 2016 5:42 PM

Answers

  • Hi. Did you just create a new record? Or, are you talking about moving the pointer to a blank record? If the latter, try:

    DoCmd.GoToRecord , , acNewRec

    Hope that helps...

    • Proposed as answer by André Santo Monday, March 14, 2016 6:28 PM
    • Marked as answer by OHMel Monday, March 14, 2016 6:36 PM
    Monday, March 14, 2016 6:17 PM
  • Thanks! It worked.

    Had to make sure the focus was set to the correct field before moving to the next record.

    If not It would start a loop and keep going...

    Private Sub Match_GotFocus()
        If [ADMScan] = [ADMReturned] Then
            Match = "OK"
        Else
            Match = "BAD"
        End If
        Me!TimeStamp.SetFocus                    <- moved focus away from the field
        DoCmd.GoToRecord , , acNewRec       <- then move to the new record.
    End Sub

    Thanks again.


    Mel

    Monday, March 14, 2016 6:38 PM

All replies

  • Hi. Did you just create a new record? Or, are you talking about moving the pointer to a blank record? If the latter, try:

    DoCmd.GoToRecord , , acNewRec

    Hope that helps...

    • Proposed as answer by André Santo Monday, March 14, 2016 6:28 PM
    • Marked as answer by OHMel Monday, March 14, 2016 6:36 PM
    Monday, March 14, 2016 6:17 PM
  • Thanks! It worked.

    Had to make sure the focus was set to the correct field before moving to the next record.

    If not It would start a loop and keep going...

    Private Sub Match_GotFocus()
        If [ADMScan] = [ADMReturned] Then
            Match = "OK"
        Else
            Match = "BAD"
        End If
        Me!TimeStamp.SetFocus                    <- moved focus away from the field
        DoCmd.GoToRecord , , acNewRec       <- then move to the new record.
    End Sub

    Thanks again.


    Mel

    Monday, March 14, 2016 6:38 PM
  • Hi Mel. Glad to hear you got it to work. Good luck with your project.
    Monday, March 14, 2016 6:59 PM