Results 1 to 3 of 3
  1. #1
    numberguy is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    15

    Control cannot receive focus

    I receive an error message (2110) "Microsoft Access Can't move focus to the control "Control Name" when using the GoToControl macro command. I have checked the recommended settings and all are proper. The issue appears to be that I have a macro in the "On Got Fucus" event in the control to which focus is being transferred. If I remove this macro the GoToControl macro command works fine.

    The Macro in the "On Got Focus" event is as follows:

    Code:
    If IsNull(DLookUp("[Grain]![Name 2]","Grain","[Account No]=" & [Forms]![Grain_Entry]![Account No]))
    Then
    Stop Macro
    End if
    
    SetValue
       Item = [Forms]![Grain_Entry]![Name 2]
       Expression =  DLookUp("[Grain]![Name 2]","Grain","[Account No]=" & [Forms]![Grain_Entry]![Account No])
    
    GoToControl
      Cotrol Name = Address 1
    The name of the control containing the macro is [Name 2]

    The focus is being transferred from control [Name 1] to control [Name 2]



    The On Got Focus Command in control [Name 1] has a smilar macro as above except the references are to [Name 1] and the GoToControl control name is [Name 2]. I do not receive the error for the [Name 1] control since it does not receive focus via a macro.

    The error message is triggered in the Macro associated with the [Name 1] control when focus is being sent to the [Name 2] control, but again the problem appears to be associated with the macro in the On Got Focus event in the control to receive focus.

    I can use the SendKeys {tab} command to get around this problem, but I am trying to avoid using the SendKeys command due to other issues with that command. Also, the Senkeys solution only works if the control to need focus is the next tab stop.

    What I am trying to accomplish is to test to see if the database already contains a record with a reference number matching the one entered in the current record being generated by the form. If it does, several of the controls in the current record are automatically updated. If it does not, the the focus is remains with the controls until user input for that control is complete.

    Thank you in advance for any help

  2. #2
    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
    To be honest, I'm having trouble following your scenario, here, but your DLookup function is misconfigured and the result is that it will always return a Null, and thus Stop Macro will execute. It should be something like

    If IsNull(DLookUp("[Name 2]","Grain","[Account No]=" & Me.[Account No])) Then

    assuming that [Account No] is on the current Form and that it is defined as a Number in the underlying Table.

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

    All posts/responses based on Access 2003/2007

  3. #3
    numberguy is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    15
    Thanks for the response.

    The Dlookup is working properly. It has to get past that test before it can make it to the GoToControl command.

    What I am trying to do is test to see if there is a record in the "Grain" table that matches the "Account No" field entered in the current form "Grain_Entry". If there is, then popluate the current control with the corresponding information from the "Gran" table. If there is not, the stop and wait for user input.

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

Similar Threads

  1. Focus in web browser control
    By bjornhe in forum Access
    Replies: 0
    Last Post: 10-27-2011, 05:10 AM
  2. Focus on Key Control
    By windwardmi in forum Access
    Replies: 1
    Last Post: 09-07-2011, 04:57 PM
  3. How to control a button when it has focus
    By shubhamgandhi in forum Programming
    Replies: 2
    Last Post: 07-28-2011, 03:18 PM
  4. Replies: 0
    Last Post: 04-11-2011, 01:39 PM
  5. Maintaining Control Focus
    By sabbo64 in forum Programming
    Replies: 3
    Last Post: 08-18-2009, 11:56 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