[AccessD] Error 2110: can't move the focus to control...

Dan Waters df.waters at comcast.net
Wed Dec 26 11:14:33 CST 2012


Hi Rocky,

I get this error fairly often in a large system so I was very interested to
read this.

I would suggest trying to set the focus before you make the graphic
invisible.  I'm going to guess that Access will have difficulty making the
image invisible if it already has the focus, or it may move the focus to the
control which is next in the tab order.  If the next control in the tab
order is TimeEntryNarrative, then you will have a problem because setting
focus to a control which already has the focus will cause an error.

Try this:

    Private Sub imgGraphicForTimeEntryNarrative_Click()
            Me.TimeEntryNarrative.SetFocus   
            Me.imgGraphicForTimeEntryNarrative.Visible = False
    End Sub

Good Luck!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Wednesday, December 26, 2012 10:23 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Error 2110: can't move the focus to control...

Dear List:
 
I am getting an error 2110: can't move the focus to the control...
 
It occurs in this code:
 
Private Sub imgGraphicForTimeEntryNarrative_Click()
    Me.imgGraphicForTimeEntryNarrative.Visible = False
    Me.TimeEntryNarrative.SetFocus
End Sub
 
in the SetFocus line.  
 
After I get the error, if I press F5 the program carries on normally setting
the focus to TimeEntryNarrative.
 
However, there is a condition that causes this.  Mostly clicking into
imgGraphicForTimeEntryNarrative (which is a graphic OVER a text box.  The
graphic shows if there's nothing in the text box and is made invisible when
there is something in the text box), works fine.
 
But if the user clicks into one of two other text boxes and then clicks
imgGraphicForTimeEntryNarrative, the error occurs.
 
Both those boxes have a LostFocus event as follows:
 
Private Sub txtEditWorkedTime_LostFocus()
 
    Me.cmdExit.SetFocus
    Me.txtEditWorkedTime.Visible = False
    Me.HoursBillable.SetFocus
 
End Sub

If I temporarily disable that module:
 
Private Sub txtEditWorkedTime_LostFocus() Exit Sub
    Me.cmdExit.SetFocus
    Me.txtEditWorkedTime.Visible = False
    Me.HoursBillable.SetFocus
 
End Sub
 
then Private Sub imgGraphicForTimeEntryNarrative_Click() works.
 
I'm not opposed to a quick fix or workaround for this.  But I have gotten
this error before - does anyone know the general cause (or general
solution)?  Odd that after I get the error I can resume code execution and
it works!
 
MTIA
 
Rocky Smolin
Beach Access Software
858-259-4334
www.bchacc.com <http://www.bchacc.com/> www.e-z-mrp.com
<http://www.e-z-mrp.com/>
Skype: rocky.smolin
 

 
 
 
 
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list