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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Key Press

Status
Not open for further replies.

Cyberjake

Technical User
Joined
Jun 5, 2003
Messages
14
Location
US
Hello,
I have a customer who would like to press the enter key to submit a command. I have never programmed On Key Press. How would I program On Key Press so that when the customer presses the enter key, it performs a submit function?

Thanks,
Anthony
 
There may be a way to use the &quot;&&quot; to allow a user to do an <alt> Key to achieve what is wanted. Would that do?


rollie@bwsys.net
 
I asked the user about that and they would like to be able to just hit the enter key and submit. I have been trying to find some information on KeyDown and KeyUp coding to see if that would help, but I have not found anything that helps.
 
Hi Cyberjake,

I'm presuming you're in a Form when you want to trap ENTER. If you want to trap keys at form level you need to set the form KeyPreview property to true and add your code in one of the Key events.

But an easier way of doing this might be to have a default command button. If you have no other buttons on the form then pressing ENTER will be the same as clicking on the button.

Enjoy,
Tony
 
That is what I am wanting to do. I have two buttons on the form a submit and a cancel. The submit checks for a true statement and then closes the form and the cancel clears the entries and closes the form.

Thanks...
 
Hey Tony,

I set the submit command button to default = yes and it works the way I want it to...I will have to remember that one.

Thanks again...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top