Results 1 to 6 of 6
  1. #1
    quicova is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    53

    SetFocus on Field in subform

    Hi Everyone.

    I'm trying to right a code to set the focus on a field in the last created record on a subform.

    I have a subform and a listbox side by side.
    I created a double click even that adds data from the listbox to the subform, but I still need to manually add more values.
    So I wanted to set the focus on the next field in the subform on the last created record.

    I tried
    [Forms].[mysubform].[specificField].SetFocus but that didn't work
    For sure I need to tell to go to last created record in the subform and them tell which field to set the focus.

    Anyone has any ideas on how to go about this?
    Thanks so much


    Quico

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    quicova is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    53
    UAU that is awesome information.
    Thanks so much.
    It stopped giving me the error but it still doesn't set the focus on the last created record.

    I'm trying something like this but I can't make it work
    Code:
    Me!Add_to_Weights_SUB.SetFocus
        Me.MoveLast
        Me.Quantity.SetFocus
    Any ideas?

    Subform name is Add_to_Weights_SUB
    Field name is Quantity

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    Me.tblTestsubform.SetFocus
    DoCmd.GoToRecord , , acLast
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    quicova is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    53
    Thanks it work.
    I forgot about the GoToRecord command.
    Thanks so much

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Requirements for SetFocus
    By EddieN1 in forum Forms
    Replies: 2
    Last Post: 09-01-2013, 06:19 PM
  2. dlook up and setfocus
    By msasan1367 in forum Access
    Replies: 3
    Last Post: 07-15-2013, 12:03 PM
  3. SetFocus after MsgBox
    By NISMOJim in forum Programming
    Replies: 18
    Last Post: 12-12-2012, 08:44 PM
  4. setfocus on an textbox different way
    By white_flag in forum Access
    Replies: 0
    Last Post: 09-21-2011, 05:04 AM
  5. Error checking field, SetFocus does not work
    By SemiAuto40 in forum Access
    Replies: 9
    Last Post: 07-26-2011, 10:08 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