[AccessD] Focus On Currrent Control After Update

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Sat Feb 25 17:09:36 CST 2006


Dan:

Approach #1 worked.  Thanks.

Rocky


Dan Waters wrote:
> Hi Rocky,
>
> I have to deal with this all the time.
>
> The point is you can't set the focus to a control that already has the
> focus.  And, you sometimes don't know if that control already has the focus.
>
>
> 1st Approach:
>
> If you have a control that is ALWAYS enabled, but you're SURE will not have
> the focus, then you can do this:
>
>     '-- Move focus 
>     txtAlwaysEnabled.SetFocus
>     txtWantFocusHere.SetFocus
>
>
> 2nd approach:
>
> First, make an unbound, visible, unlocked, enabled textbox with transparent
> background and border.  Call it txtSetFocusOnPurpose.
>
>     '-- Move focus
>     txtSetFocusOnPurpose.SetFocus
>     txtWantFocusHere.SetFocus
>
>
> 3rd Approach:  (Which I never had much luck with)
>
>     '-- Move focus
>     If Screen.ActiveControl.Name <> "txtWantFocusHere" Then
>         txtWantFocusHere.SetFocus
>     End If
>
>
> Hope this is of some help!
>
> Dan 
>  
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin -
> Beach Access Software
> Sent: Saturday, February 25, 2006 1:56 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] Focus On Currrent Control After Update
>
> Dear List:
>
> I have the following module:
>
> Private Sub fldContainerCheck1_AfterUpdate()
>     If CheckTheCheck(fldContainerCheck1) = False Then
>         fldContainerCheck1 = ""
>         Me(Screen.ActiveControl.Name).SetFocus
>     End If
>    
> End Sub
>
> if the function CheckTheCheck returns fasle then I want to set the focus 
> back on the field fldContainerCheck1.
>
> If I write Me(Screen.ActiveControl.Name).SetFocus or 
> Me.fldContainerCheck1.SetFocus the focus ends up on the next control in 
> tab order.
>
> If I write Me(Screen.PreviousControl.Name).SetFocus the focus ends up on 
> the previous control in tab order.
>
> How can I get the focus back on the field that has the problem?
>
> I tried     If CheckTheCheck(fldContainerCheck1) = False Then 
> Me.fldContainerCheck1.Undo
>
> in both before and after update events but it didn't undo the entry.  I 
> don't want to undo the entire record at this point, just blank the field 
> with the bad number and set the focus there.
>
> MTIA
>
> Rocky
>
>
> SetFocus
>
>   

-- 
Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com




More information about the AccessD mailing list