Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Posts
    37

    Unanswered: run time error 2110

    Hello there,

    Controls("heb" & G_Grid).SetFocus

    This line woked ok on access 2003. Now in access 2007 it comes with an error
    can't move focus.

    Any Idea how to get over this problem?

    Thanks

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    What is the error? Can't set the focus or control not found or something else?

    Is the control disabled? If so, SetFocus fails.

    What is G_Grid? If it's a variable, is it a string, a number or something else? in the context shown, Access will try to convert it to a string and a number may get a leading space, which changes the value of the string. If it's another control on the form, is Value the default property? Is it null?

    Add a break point on this line of code, run it and in the immediate window type:
    Code:
    ? "heb" & G_Grid
    When you hit enter, you will see what the literal is after Access has converted it.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  3. #3
    Join Date
    May 2007
    Posts
    37

    run time error 2110

    This line is a routine in a calendar that consist of 42 text boxes by the name "Heb"
    and the G_Grid is an integer variable that is added to name of the text box in this case "Heb3".

    Controls("heb" & G_Grid).SetFocus suppose to set the focus on this text box.
    it was working perfectly in access 2003 and for some reason it is not working on access 2007.

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    If G_Grid is an integer and it is equal to 3, then the value of "heb" & G_Grid = "heb 3" which is not the same as "heb3".

    I'm surprised you did not encounter that in Access 2003 since the method of implicitly converting data types hasn't changed all that much. I'm guessing there is something else in the 2003 version that lead to it working. In any case, try Me.Controls("heb" & Format(G-Grid)).SetFocus

    Using the Me ensures Access is associating Controls with the right parent object and using Format explicitly converts a number to a string with no leading space.

    You never did say what the error message was.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  5. #5
    Join Date
    May 2007
    Posts
    37
    The message is
    Run-Time Error '2110': Microsoft Access Can't Move The Focus To The Control Heb3

    I've tried the code : Me.Controls("heb" & Format(G-Grid)).SetFocus
    you've suggested and i get the same error.

  6. #6
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    ok, the message indicates the correct name is being grabbed (Heb3).
    You verified Heb3 exists, correct?

    Beyond that, the most common reasons for a control to not take focus are:
    1) The control has Visible false or Enabled false
    2) The container has Visible false or Enabled false (subform, tab control ,etc.)
    3) It can't find the control

    Put a break point in the code and check the status of the control in the Immediate Window.

    Since you mentioned the move from Access 2003 to 2007 several times, did you verify the references are still valid and that ADO and DAO aren't getting crossed? If a reference is no longer valid, Access will gag at obscure, unrelated points of code.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  7. #7
    Join Date
    May 2007
    Posts
    37
    I have a bug in the program on a specific date.
    I've realized that it happens also on the 2003 version for this specific date.

    Thank you for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •