SetFocus Statement

Templer

Registered User.
Local time
Today, 17:57
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?
 
The GotFocus event is triggered the second it receives the focus, as it is supposed to
 
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

Back
Top Bottom