Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox Keydown KeyCode Not Defined Error

Status
Not open for further replies.

Mav3000

Technical User
Jun 20, 2005
113
GB
Hi All,

I have a form with a textbox which I monitor for the user pressing 'Enter' on their keyboard. My function looks like this:

Code:
Private Sub tbxPassword_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

'  Attempt login If Enter Is Pressed
   If KeyCode = 13 Then LoginProcess

End Sub

This morning, this worked fine, every time. Then suddenly when I run the form, I get the error "Sub or Function Not Defined" on 'If KeyCode', even though it clearly appears in the event declaration above.

Why is this happening, and happening seemingly out of the blue?!

Any help would be appreciated. Google doesn't yield any results.

Mav3000
 
All sorted - the function I was calling on the KeyCode = 13 was invalid, however Excel was telling me that KeyCode itself was the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top