Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Default commandbutton

Hi,

I have userform with few textboxes and few commandbuttons. my question is
how to make that after i will finish entering data to one of the textboxs and
click Enter specific commandbutton will be executed.

Thanks in advance
Eli
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Default commandbutton

I have userform with few textboxes and few commandbuttons. my question is
how to make that after i will finish entering data to one of the textboxs
and
click Enter specific commandbutton will be executed.


Set the Default property to True for the CommandButton whose Click event
code you want to execute whenever the Enter key is pressed. If you need to
know which control had focus when the Enter key was pressed, set up a
form-wide global variable in the form window's (General)(Declarations)
section and Set this variable to the control object in each control's Enter
event. Maybe something like this, as a starting framework, for example...

Dim LastControl As Control

Private Sub CommandButton1_Click()
Debug.Print LastControl.Name
End Sub

Private Sub TextBox1_Enter()
Set LastControl = TextBox1
End Sub

Private Sub TextBox2_Enter()
Set LastControl = TextBox2
End Sub

Rick

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
commandbutton? Bobbykm Excel Programming 3 September 30th 07 01:13 AM
Commandbutton alvin Kuiper Excel Programming 6 November 27th 05 06:28 PM
CommandButton Alvin Hansen[_2_] Excel Programming 3 August 16th 04 06:35 PM
CommandButton chris[_12_] Excel Programming 1 April 15th 04 01:01 AM
CommandButton rwebster3 Excel Programming 0 April 14th 04 08:16 PM


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"