+ Reply to Thread
Results 1 to 6 of 6

how to detect a user <cr> into vba?

  1. #1
    Registered User
    Join Date
    09-18-2003
    Posts
    39

    how to detect a user <cr> into vba?

    Hello,
    I would like to detect if the user hits the {ENTER} key to be able to perform operation in a UserForm.
    I feel it's a very basic question, but can't find out myself!
    Thx in advance,
    D

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You can use the KeyUp of a commandbutton

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    If you want to check to see if they pressed enter within a textbox (assuming your form doesn't have a default command button), this could also work:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-18-2003
    Posts
    39

    precision

    It seems I haven't been clear enough...
    I want to detect if the user hit the enter key but without the need of asking him the question!
    A calendar is open, the user can move from date to date using the arrows, I want him to confirm the date he wants with the enter button of the keyboard (instead of clicking with the mouse).
    The suggestion of Paul seems perfect, but doesn't work on my end. I tried the KeyDown property in the UserForm code, and in the Calendar1 code, but also the KeyPress and Enter properties with no more luck. See code below.
    I feel that I am on the good path, but a little something seems to be missing...
    D
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    This worked fine for me:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-18-2003
    Posts
    39
    It works!
    I don't know what I did wrong, but everything is working perfectly now!
    Thx again 4 your fast answers
    D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1