-
I have a simple data entry form. I would for the user to be able to use the enter key to tab through the form. I am having trouble with a command button. I can use the enter key to get the focus of the cmd button, but when I hit the enter key again it skips a field(instead of going to fld 2 it goes to fld3) Need help!!
-
What's the code you're using to do it?
-
Hi Harry
this is the code for the cmd button, at the end i have enabled the textboxes. I als o set the keypreview to true on the form level.
Private Sub cmdNewClient_Click()
Debug.Print "cmdNewClient fired"
Dim Response
Dim MaxID
Dim CLIENT As String
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
'Adds new Client
cn.ConnectionString = deAgency.conAgency.ConnectionString
cn.Open
rs.Open "SELECT MAX (CLIENTID) AS maxi FROM Clients", cn, , adLockReadOnly, 1
rs.MoveFirst
MaxID = rs.Fields("maxi").Value
CLIENT = UCase(cbClient.Text)
deAgency.rsClients.AddNew
deAgency.rsClients.Fields("CLIENTID").Value = MaxID + 1
deAgency.rsClients.Fields("CLIENT").Value = CLIENT
deAgency.rsClients.Update
cbClient.Text = CLIENT
lblClientID.Caption = MaxID + 1
rs.Close
cn.Close
txtInterviewLength.Enabled = True
txtFieldMgmt.Enabled = True
txtMethod.Enabled = True
txtJOBTITLE.Enabled = True
txtIncidence.Enabled = True
txtQualifications.Enabled = True
cmdNewClient.Enabled = False
-
I kind of meant the code to move the focus :)
-
I have used both kepup and keypress
if keycode/keyascii = 13 then txtInterviewLenght.setfocus, but it never goes to either procedure
-
Hmm, perhaps the event in which you set the focus is executed before the code in the button - if the text box isn't enabled I don't think it can receive the focus.