SetFocus Statement (1 Viewer)

Templer

Registered User.
Local time
Today, 17:33
Joined
Sep 26, 2002
Messages
10
Hi everyone,

Can anyone tell me what is wrong with this piece of code?

Private Sub HeaderAcc_Enter()
On Error GoTo Err_HeaderAcc_Enter

Address1.SetFocus

Exit_HeaderAcc_Enter:
Exit Sub

Err_HeaderAcc_Enter:
MsgBox Err.Description
Resume Exit_HeaderAcc_Enter

End Sub

When I tab to the field HeaderAcc the SetFocus statement is immediately actioned, why doesn't it wait for me to press enter?
 

EndersG

Registered User.
Local time
Today, 17:33
Joined
Feb 18, 2000
Messages
84
The GotFocus event is triggered the second it receives the focus, as it is supposed to
 

dgm

Registered User.
Local time
Tomorrow, 02:33
Joined
Sep 5, 2002
Messages
146
You want something like this:
Code:
Private Sub HeaderAcc_KeyDown(KeyCode As Integer, Shift As Integer)
    ' Get return key
    If KeyCode = 13 Then
        Address1.SetFocus
    End If
End Sub
Although you should be able to change the tab order to do this, unless your doing something out of the ordinary.:D

Dave
 

Users who are viewing this thread

Top Bottom