Stuart McLachlan
stuart at lexacorp.com.pg
Thu Dec 27 15:05:57 CST 2012
Doesn't look too kludgey for me :-) That's much better than using setfocus inside a lostfocus event. -- Stuart On 27 Dec 2012 at 8:23, Rocky Smolin wrote: > OK here's what worked but it's kludgey: > > Private Sub imgGraphicForTimeEntryNarrative_Click() > > Me.cmdExit.SetFocus > Me.txtEditWorkedTime.Visible = False > Me.txtEditBillableTime.Visible = False > Me.imgGraphicForTimeEntryNarrative.Visible = False > Me.TimeEntryNarrative.SetFocus > > End Sub > > I disabled the lost focus events for those two text boxes and make them > invisible in the Sub imgGraphicForTimeEntryNarrative_Click(). If the user > is not clicking into the imgGraphicForTimeEntryNarrative object from one of > those boxes then they're already invisible and the two statements have no > effect. > > Works - but try to explain it to the next programmer. :) > > Rocky > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin > Sent: Thursday, December 27, 2012 8:16 AM > To: 'Access Developers discussion and problem solving' > Subject: Re: [AccessD] Error 2110: can't move the focus to control... > > Dan: > > I didn't need luck - just your solution - which worked perfectly. Thanks. > > Rocky Smolin > Beach Access Software > 858-259-4334 > www.bchacc.com > www.e-z-mrp.com > Skype: rocky.smolin > > P.S. Why I love this list... > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters > Sent: Wednesday, December 26, 2012 9:15 AM > To: 'Access Developers discussion and problem solving' > Subject: Re: [AccessD] Error 2110: can't move the focus to control... > > 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! >