Results 1 to 3 of 3
  1. #1
    warrenpage is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Oct 2013

    Command Button: Add New Record, then Set Focus to a Specific Field

    Could I please get a little help creating a command button?

    I know how to create a command button that adds a new record to a form. But I need a command button that will add a new record to a form, and then set the tab focus to a specific field. I'm not sure how to do that.

    I found some VB code through a Google search: Forms!Employees!EmployeeID.SetFocus

    I modified it to work with a command button: Forms!frmGenre!MainGenre.SetFocus

    And this worked. But I am not yet sure how to write code to add a new record. Is it possible to create a command button using the Command Button Wizard, that will let me add a new record to the form, and then also plug in this VB code? If that's possible, I'm not 100% sure how to do that. I'm basically a novice and haven't dabbled all that much with macros or VB yet. But I am ready and willing to learn.

    Thanks! Warren Page

  2. #2
    warrenpage is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Oct 2013
    I think I figured it out through researching the web.

    I got two separate pieces of code. I plopped them into a command button's code builder window, and it seems to work. Here's the code I used.

    Private Sub cmdNewActor_Click()
    DoCmd.GoToRecord , , acNewRec
    End Sub

    It seems to work, so I'm sticking with it. Research is your friend!

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Nevada, USA
    Thanks for posting your solution; it could help somebody later. I'll mark this thread solved for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019

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

Similar Threads

  1. Replies: 9
    Last Post: 08-20-2013, 09:59 AM
  2. Replies: 12
    Last Post: 03-14-2012, 10:54 AM
  3. Replies: 3
    Last Post: 12-17-2011, 02:32 PM
  4. Replies: 11
    Last Post: 06-02-2011, 10:21 AM
  5. Replies: 2
    Last Post: 03-10-2009, 05:14 PM

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 - Senior Forums