Results 1 to 8 of 8
  1. #1
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11

    Set Focus to Field after Add Record

    Hi



    I would like to add an action to my "Add Record" button so that after it has completed adding the record that it sets the focus to my order number field as that is scanned in by a hand held scanner. It does not seem to be an option to add SetFocus as an action, how would I go about this?

    Thanks in advance for the assistance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Me.controlname.SetFocus

    Post button code if you need more help.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11
    Click image for larger version. 

Name:	Capture.PNG 
Views:	18 
Size:	8.2 KB 
ID:	37875
    I just have it as the default add record button, can I add that line of code to that?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I don't use macros, only VBA. I am not finding SetFocus available in macro actions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Testing shows that you have to use the GoToControl action in Macros...then enter the Control name in the lower half of the Macro Design View.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Another option you could try is to set the "order number" control tab index to 0 (zero). When you save the current record, then go to a new record, the control with a tab index of zero gets the focus... No code required...

  7. #7
    ShennyP is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    11
    The GoToControl action worked, thank you!

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help!

    Welcome to AFN!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 2
    Last Post: 07-10-2017, 12:30 AM
  2. Replies: 5
    Last Post: 10-18-2016, 06:00 AM
  3. How to set focus on record just added
    By GraeagleBill in forum Forms
    Replies: 10
    Last Post: 03-08-2016, 10:38 PM
  4. Replies: 17
    Last Post: 03-16-2014, 10:52 PM
  5. Replies: 2
    Last Post: 11-01-2013, 09:57 AM

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