Results 1 to 4 of 4
  1. #1
    Danny0803 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2

    How to go to a specific Field using VBA

    Hello there,

    I have a search box that opens a form using a filter. When I type the information I want to search in form, it works fine.
    However, I am trying also to add the code that when the new form is open the cursor goes to a specific field in the new form.

    Here is the code i have so far:

    Private Sub cboSearch_click ()


    DoCmd.OpenForm "frmSighOut", acNormal , , "[VehNumber]= ' "Me.txtSearch & " ' "
    DoCmd.Close acForm, "frmVehSearch"

    End Sub


    Please help!!

    Thank you,

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Use
    Code:
    Me.controlName.SetFocus
    Change controlName to your control name.

  3. #3
    Danny0803 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    2
    Quote Originally Posted by Danny0803 View Post
    Hello there,

    I have a search box that opens a form with a subform using a filter. When I type the information I want to search in form, it works fine.
    However, I am trying also to add the code that when the new form is open the cursor goes to a specific field in the subform.

    Here is the code i have so far:

    Private Sub cboSearch_click ()
    DoCmd.OpenForm "frmSighOut", acNormal , , "[VehNumber]= ' "Me.txtSearch & " ' "
    dDCmd.GoToControl Form!frmSignOut!frmSubSignout.FirstName.SetFocus (I am getting a Error)
    DoCmd.Close acForm, "frmVehSearch"

    End Sub

    I need to add the code to get to the subform.


    Please help!!

    Thank you,
    I am trying to go to the subform, once the main form is opened, and is not working.

    I added the following line

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You didn't have "subform" in the original post.
    You have too many "d"s:
    dDCmd.GoToControl ............



    Try:
    Code:
    Me!frmSubSignout.Form!FirstName.SetFocus

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

Similar Threads

  1. Replies: 1
    Last Post: 07-01-2016, 08:24 AM
  2. Replies: 4
    Last Post: 05-18-2016, 03:32 PM
  3. Replies: 16
    Last Post: 01-05-2016, 04:13 PM
  4. Replies: 2
    Last Post: 01-14-2015, 12:00 PM
  5. Replies: 1
    Last Post: 11-20-2014, 08:34 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