Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XP (Set Focus to Field)

    I am trying to make sure that anytime a new record is entered the focus always goes to the first field. I have it working for everything except when the user is on a different field on the last record and then presses the right arrow on the record scroll bar to add a new record. A new record is entered, but the focus stays in the field that the cursor was in before pressing the right arrow. Does this make sense? Any suggestions?

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

    Re: XP (Set Focus to Field)

    You can write code in the OnCurrent event that checks if you have navigated to a new record, and if so, sets the focus to the first control.

    Private Sub Form_Current()
    If Me.NewRecord = True Then
    Me.FirstControl.SetFocus
    End If
    End Sub

    Substitute the name of the "first" control for FirstControl.

  3. #3
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP (Set Focus to Field)

    Seems to work fine. Thanks!

  4. #4
    New Lounger
    Join Date
    May 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP (Set Focus to Field)

    say u have field name ( text1 )

    then put this code after docmd.addnewrecord

    text1.setfocus

    ...............

Posting Permissions

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