human_anomaly
Registered User.
- Local time
- Yesterday, 19:30
- Joined
- Apr 12, 2004
- Messages
- 69
I have a textbox that I want to check for the keypress event. It does as I ask but the key I am checking for is the enter key (otherwise known as vbKeyReturn) when i hit the enter key in the text box the keypress event doesn't run and it changes its focus to the next item. Is there a way I can turn of the focus change everytime you hit the enter key, i'm not sure if that indeed is the problem but I am willing to give it a try. Here is my code:
Private Sub Command15_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If TxtLName <> "" And TxtFName <> "" Then
Student.Value = TxtLName + ", " + TxtFName
On Error GoTo Err_enter_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
TxtLName.Value = ""
TxtFName.Value = ""
TxtFName.SetFocus
Else
MsgBox ("You cannot leave a field blank")
End If
End If
Exit_enter_Click:
Exit Sub
Err_enter_Click:
MsgBox Err.Description
Resume Exit_enter_Click
End Sub
Private Sub Command15_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If TxtLName <> "" And TxtFName <> "" Then
Student.Value = TxtLName + ", " + TxtFName
On Error GoTo Err_enter_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
TxtLName.Value = ""
TxtFName.Value = ""
TxtFName.SetFocus
Else
MsgBox ("You cannot leave a field blank")
End If
End If
Exit_enter_Click:
Exit Sub
Err_enter_Click:
MsgBox Err.Description
Resume Exit_enter_Click
End Sub