Results 1 to 13 of 13
  1. #1
    Join Date
    Apr 2003
    Posts
    280

    Unanswered: How do capture the value for 'Enter' on the keyboard?

    I'm doing a password form with a textbox(for the password) and two command button(one for OK and one for Cancel). When the user enter in the password, they have the option to click enter on the keyboard to intialize the code or click the OK button.

  2. #2
    Join Date
    Sep 2003
    Location
    Los Angeles
    Posts
    103

    Re: How do capture the value for 'Enter' on the keyboard?

    Originally posted by lansing
    I'm doing a password form with a textbox(for the password) and two command button(one for OK and one for Cancel). When the user enter in the password, they have the option to click enter on the keyboard to intialize the code or click the OK button.


    Try to test if the (keycode=13) on the text's (keyDown) event.

  3. #3
    Join Date
    Apr 2003
    Posts
    280
    It work! Thanks!

  4. #4
    Join Date
    Sep 2003
    Posts
    17
    If you are using VBA, you would probably be better with a VBA assignment using a case statement, ie

    Select Case Keycode
    Case VBKeyReturn
    'Do something here
    Case VBKeyD
    'Do something here
    End Select

  5. #5
    Join Date
    Apr 2003
    Posts
    280
    Originally posted by D Willett
    If you are using VBA, you would probably be better with a VBA assignment using a case statement, ie

    Select Case Keycode
    Case VBKeyReturn
    'Do something here
    Case VBKeyD
    'Do something here
    End Select
    What the difference between VBKeyReturn and VBKeyDown?

  6. #6
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    Originally posted by lansing
    What the difference between VBKeyReturn and VBKeyDown?
    Return = Enter, Down = Arrow down
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  7. #7
    Join Date
    Sep 2003
    Posts
    17
    Originally posted by lansing
    What the difference between VBKeyReturn and VBKeyDown?
    Are you confusing the KeyDown property ?

    If you put a function or statement in the KeyDown property, whatever key you press, the code will run.
    My example explicitly defines the VBKeyReturn as the key to fire the code.

    Another good idea is to create a macro "AutoKeys" and diminish the keys you don't want conflicting with your assigned keys.

  8. #8
    Join Date
    Apr 2003
    Posts
    280
    Originally posted by D Willett
    Are you confusing the KeyDown property ?

    If you put a function or statement in the KeyDown property, whatever key you press, the code will run.
    My example explicitly defines the VBKeyReturn as the key to fire the code.

    Another good idea is to create a macro "AutoKeys" and diminish the keys you don't want conflicting with your assigned keys.
    Not really, if you put it under the textbox method.

    For example, my textbox name is txtPassword, in VBA I would put "If KeyCode = 13 then" in the KeyDown method(txtPassword_KeyDown) sub procedure. This wouldn't affect anything else if press enter. As long as the cursor is in the textbox then it would run that specific code that I hard coded in.

    Unless, there is something you are telling me that I don't have a clear picture yet.

  9. #9
    Join Date
    Sep 2003
    Posts
    17
    Yes you are correct.

    Your text box method is how you want to return the key event.
    What I meant was the KeyDown event of the form !

    Lets say you want to close the form with one specific key, ie F10

    The property would be better in the form event as opposed to the text control:-

    Select Case KeyCode
    Case VBKeyF10
    Docmd.Close acForm,Me.Name
    End Select

    This would be the event for all of the form.
    Now if you doubled your keys, Form & Text with the same key value, You would run into problems because you would be firing two sets of code.

    The AutoKeys macro on the other hand can be useful for ALL of the database.
    ie
    {F10}
    Close Form
    Form Name

    Pressing the F10 key will close any form which has the focus.
    It depends how you set your macro.

    I still recommend using the VB key name assignments.
    Using character values can cause problems as your database progress's

  10. #10
    Join Date
    Apr 2003
    Posts
    280
    Originally posted by D Willett
    Yes you are correct.

    Your text box method is how you want to return the key event.
    What I meant was the KeyDown event of the form !

    Lets say you want to close the form with one specific key, ie F10

    The property would be better in the form event as opposed to the text control:-

    Select Case KeyCode
    Case VBKeyF10
    Docmd.Close acForm,Me.Name
    End Select

    This would be the event for all of the form.
    Now if you doubled your keys, Form & Text with the same key value, You would run into problems because you would be firing two sets of code.

    The AutoKeys macro on the other hand can be useful for ALL of the database.
    ie
    {F10}
    Close Form
    Form Name

    Pressing the F10 key will close any form which has the focus.
    It depends how you set your macro.

    I still recommend using the VB key name assignments.
    Using character values can cause problems as your database progress's
    hmm, that's a good idea but the password is it form by itself, so I don't have to worry about conflicting it with other coding with the same value in the near future.

  11. #11
    Join Date
    Apr 2003
    Posts
    280
    What is the enter keyboard value for the one that is on the far right side of the keyboard.

  12. #12
    Join Date
    Apr 2003
    Posts
    280
    n/m

  13. #13
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    Originally posted by lansing
    What is the enter keyboard value for the one that is on the far right side of the keyboard.
    It'S the same as the usual ENTER.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •