?
Solved

Esc and Enter in Form

Posted on 2003-03-28
5
Medium Priority
?
193 Views
Last Modified: 2010-05-01
I have a form with 2 command buttons. One is cancel, and one is ok. I have many text boxes for the user to input. When user presses 'Enter' I want it to go like "ok" and if user presses 'Esc' I want it to make as "Cancel". Any help?

Thanks everyone!
0
Comment
Question by:igfp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 4

Accepted Solution

by:
trkcorp earned 80 total points
ID: 8227763
Set the Default property of the button you want to execute on enter to True.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 8227797
As for the Esc portion, you could set the KeyPreview property = True on the FORM and when the user presses Esc execute the button's click event. Like:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then cmd_Click
End Sub
0
 
LVL 5

Expert Comment

by:YaakovS
ID: 8227804
setting the cancel property to true will activate it's click event when the user presses Esc.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 8227816
OOPS! YaakovS is correct!
0
 

Author Comment

by:igfp
ID: 8229844
Thank man! Points go to you as you were the first to do this! I apreciate both helps. Life savers!!! :p
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question