PC Review


Reply
Thread Tools Rate Thread

Default commandbutton

 
 
אלי
Guest
Posts: n/a
 
      28th Dec 2007
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
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      28th Dec 2007
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get commandbutton name =?Utf-8?B?U2Vhbg==?= Microsoft Excel Programming 2 17th Oct 2006 08:49 AM
commandbutton =?Utf-8?B?U3RldmVu?= Microsoft Access Form Coding 2 7th Aug 2006 10:16 PM
Commandbutton Sadik Microsoft Excel Programming 1 12th Mar 2004 07:07 PM
Commandbutton David Fixemer Microsoft Excel Programming 2 25th Feb 2004 10:18 PM
CommandButton? Stu Microsoft Excel Discussion 7 19th Oct 2003 03:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.