Results 1 to 4 of 4
  1. #1
    ynotaz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    9

    Set focus run time error on continuouse form

    Here is the circumstance and request for help.



    I have an invoice form, which has a continuous sub form for line items. I allow a user to double click on the item number in the sub form to bring up a modal search form to look for items. If they find an item and double click it in the modal form, I insert the item in the invoice sub form and set the focus to the quantity field, then closes the modal form. that works fine.

    Here is the complicated part that does not work.

    Some special items when added to the sub form by direct keying or programmatic entry as I described above, cause additional processing triggered by the after update event on the item number field. One such item causes the automatic insert of a second item on the sub form. This is where the error occurs. When I issue the set focus, just before closing the modal form, I get a run time error 2110 "cannot move focus to the quantity control". If I select "end" from the debug dialog box, everything is inserted correctly the focus is on the item number of the first item of the continuous form. If I close the modal form manually, it's like everything worked fine except that the focus is on the first line item, item number field. The processing can continue as though there was no error from this point.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The whole reason for modal is so focus cannot be moved off that form until it closes. I seldom use Modal. I open form programmatically with the acDialog parameter. This will suspend code execution by the calling form until the dialog form closes. So put the SetFocus code in the main form to resume processing after the dialog form closes.
    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
    ynotaz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    9
    OK, I will do some playing with moving code to the main or sub form.

    Funny part is it works 98% of the time when it is one line item. It only fails on the 2% when the sub form inserts a second line.

    Thanks for the suggestion
    Last edited by ynotaz; 03-20-2017 at 05:51 PM. Reason: none

  4. #4
    ynotaz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    9
    I played with this a lot but ended up changing the format of my set focus command to the following:

    Forms!Invoice!InvLine!Qty.SetFocus

    Then a requery of the sub-form

    Forms!Invoice!InvLine.Requery

    And it works in all cases now.

    Thanks for the suggestion, it made me think through the problem in a different light.

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

Similar Threads

  1. Replies: 15
    Last Post: 05-12-2016, 02:27 PM
  2. Replies: 7
    Last Post: 11-01-2013, 03:17 PM
  3. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  4. Set Focus causes RunTime Error 2108
    By ResearchRN in forum Programming
    Replies: 8
    Last Post: 12-12-2012, 08:32 AM
  5. Replies: 0
    Last Post: 02-22-2011, 04:18 PM

Tags for this Thread

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