Results 1 to 5 of 5
  1. #1
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107

    "Losing" cursor after running import macro

    I have a combobox and a textbox on a subform that both run VBA code after_update in which I have added a docmd.runmacro command that runs a macro that imports an excel spreadsheet. Before adding this command, I was able to enter data in these fields and tab to the next field. After adding this command, I've lost track of the cursor and must click the combobox or textbox and then tab or click the next entry box to continue entering data. This disrupts the data entry flow immensely. How do put the cursor back in the field using VBA code so that flow is not disrupted? I have tried using the .SetFocus and .SelStart=0 properties of the objects at the end of the after_update event of that, but the cursor is still in limbo. I tried adding a me.refresh and me.requery after the .SetFocus and .SelStart commands, but still no luck. I'm sure the answer is simple, but it is eluding me.

    Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you tried setting the focus to "next entry box to continue entering data"?

  3. #3
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107
    Quote Originally Posted by RuralGuy View Post
    Have you tried setting the focus to "next entry box to continue entering data"?
    I tried it, and it didn't work either. I also tried adding the form and subform path in front of the object name (Forms!frmOrderHeaderEntry!frmOrderDetailEntry.For m.CustItemNumberCombo.SetFocus) and that didn't work either.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Setting focus to a control on a SubForm is a two step process. 1st, set the focus to the SubForm Control:

    Forms!frmOrderHeaderEntry!frmOrderDetailEntry.SetF ocus

    ...THEN to the Control on the SubForm:

    Forms!frmOrderHeaderEntry!frmOrderDetailEntry.Form .CustItemNumberCombo.SetFocus

  5. #5
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107
    Quote Originally Posted by RuralGuy View Post
    Setting focus to a control on a SubForm is a two step process. 1st, set the focus to the SubForm Control:

    Forms!frmOrderHeaderEntry!frmOrderDetailEntry.SetF ocus

    ...THEN to the Control on the SubForm:

    Forms!frmOrderHeaderEntry!frmOrderDetailEntry.Form .CustItemNumberCombo.SetFocus
    I tried this also to no avail. I gave up and moved running my macro to the form's on current event. I think will do what I want it to without the hassle of "relocating" the cursor.

    Thanks for your help, RuralGuy.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-21-2016, 09:57 AM
  2. Can't test code - "Debug" - "Run to Cursor"
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 05-15-2016, 05:16 PM
  3. Replies: 2
    Last Post: 01-04-2016, 04:44 AM
  4. Losing my mind. "Extra ) in query expression"
    By shin_mitsugi in forum Access
    Replies: 6
    Last Post: 11-25-2015, 08:33 AM
  5. Replies: 1
    Last Post: 08-23-2012, 08:32 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