PC Review


Reply
Thread Tools Rate Thread

calling an _Exit event

 
 
SMS
Guest
Posts: n/a
 
      7th Oct 2009


Hi All...

The _Exit event for a textbox say, is called when leaving the textbox
(anything to cause a loss of focus, it seems).

I am used to being able to call events from code directly (ex: _change
events). This is proving harder for the _Exit event, as it requires a
special cancel argument. Using 0 or 1 or False or True does not work,
as it is not a normal boolean.

Could someone demonstrate for me how to call the _Exit event of a
textbox?

Thank you!

SMS
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      7th Oct 2009
Don't know if this helps but this is from the VBA Help file:

The Enter and Exit events are similar to the GotFocus and LostFocus events
in Visual Basic. Unlike GotFocus and LostFocus, the Enter and Exit events
don't occur when a form receives or loses the focus.

For example, suppose you select the check box that initiates the Enter
event. If you then select another control in the same form, the Exit event
is initiated for the check box (because focus is moving to a different
object in the same form) and then the Enter event occurs for the second
control on the form.

Because the Enter event occurs before the focus moves to a particular
control, you can use an Enter event procedure to display instructions; for
example, you could use a macro or event procedure to display a small form or
message box identifying the type of data the control typically contains.

Note To prevent the control from losing focus, assign True to the Cancel
argument of the Exit event.




"SMS" <(E-Mail Removed)> wrote in message
news:74e45cb5-2a96-4839-b80f-(E-Mail Removed)...
>
>
> Hi All...
>
> The _Exit event for a textbox say, is called when leaving the textbox
> (anything to cause a loss of focus, it seems).
>
> I am used to being able to call events from code directly (ex: _change
> events). This is proving harder for the _Exit event, as it requires a
> special cancel argument. Using 0 or 1 or False or True does not work,
> as it is not a normal boolean.
>
> Could someone demonstrate for me how to call the _Exit event of a
> textbox?
>
> Thank you!
>
> SMS



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      7th Oct 2009
I re-read your post and I think this is what you are looking for:

If the TextBox is on a sheet and you call from within the sheet code module
or if it is on a UserForm and you call from the form code module:

Private Sub TextBox1_Exit()
'Code here
End Sub

Calling a Private Sub from outside its host (Sheet or UserForm) can be a
little tricky. For the UserForm, the form would have to be visible and
modeless. I have never tried to initiate an event code without actually
having the event occur and my dim wit cannot visualize how that would even
be necessary.

"JLGWhiz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Don't know if this helps but this is from the VBA Help file:
>
> The Enter and Exit events are similar to the GotFocus and LostFocus events
> in Visual Basic. Unlike GotFocus and LostFocus, the Enter and Exit events
> don't occur when a form receives or loses the focus.
>
> For example, suppose you select the check box that initiates the Enter
> event. If you then select another control in the same form, the Exit event
> is initiated for the check box (because focus is moving to a different
> object in the same form) and then the Enter event occurs for the second
> control on the form.
>
> Because the Enter event occurs before the focus moves to a particular
> control, you can use an Enter event procedure to display instructions; for
> example, you could use a macro or event procedure to display a small form
> or message box identifying the type of data the control typically
> contains.
>
> Note To prevent the control from losing focus, assign True to the Cancel
> argument of the Exit event.
>
>
>
>
> "SMS" <(E-Mail Removed)> wrote in message
> news:74e45cb5-2a96-4839-b80f-(E-Mail Removed)...
>>
>>
>> Hi All...
>>
>> The _Exit event for a textbox say, is called when leaving the textbox
>> (anything to cause a loss of focus, it seems).
>>
>> I am used to being able to call events from code directly (ex: _change
>> events). This is proving harder for the _Exit event, as it requires a
>> special cancel argument. Using 0 or 1 or False or True does not work,
>> as it is not a normal boolean.
>>
>> Could someone demonstrate for me how to call the _Exit event of a
>> textbox?
>>
>> Thank you!
>>
>> SMS

>
>



 
Reply With Quote
 
SMS
Guest
Posts: n/a
 
      9th Oct 2009

Hi,

thanks very much for trying...

actually, and I know it can make a difference, this is a control on a
userform.

I know how to write the _Exit event, what I need is a way to call the
event from code. It already triggers when the actual event
happens.... but I do like to be able to force the event.

Does that make sense?

SMS


On Oct 7, 3:15*pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:
> I re-read your post and I think this is what you are looking for:
>
> If the TextBox is on a sheet and you call from within the sheet code module
> or if it is on a UserForm and you call from the form code module:
>
> Private Sub TextBox1_Exit()
> * *'Code here
> End Sub
>
> Calling a Private Sub from outside its host (Sheet or UserForm) can be a
> little tricky. *For the UserForm, the form would have to be visible and
> modeless. *I have never tried to initiate an event code without actually
> having the event occur and my dim wit cannot visualize how that would even
> be necessary.
>
> "JLGWhiz" <JLGW...@cfl.rr.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Don't know if this helps but this is from the VBA Help file:

>
> > The Enter and Exit events are similar to the GotFocus and LostFocus events
> > in Visual Basic. Unlike GotFocus and LostFocus, the Enter and Exit events
> > don't occur when a form receives or loses the focus.

>
> > For example, suppose you select the check box that initiates the Enter
> > event. If you then select another control in the same form, the Exit event
> > is initiated for the check box (because focus is moving to a different
> > object in the same form) and then the Enter event occurs for the second
> > control on the form.

>
> > Because the Enter event occurs before the focus moves to a particular
> > control, you can use an Enter event procedure to display instructions; for
> > example, you could use a macro or event procedure to display a small form
> > or message box identifying the type of data the control typically
> > contains.

>
> > Note To prevent the control from losing focus, assign True to the Cancel
> > argument of the Exit event.

>
> > "SMS" <r...@sonic.net> wrote in message
> >news:74e45cb5-2a96-4839-b80f-(E-Mail Removed)...

>
> >> Hi All...

>
> >> The _Exit event for a textbox say, is called when leaving the textbox
> >> (anything to cause a loss of focus, it seems).

>
> >> I am used to being able to call events from code directly (ex: _change
> >> events). *This is proving harder for the _Exit event, as it requiresa
> >> special cancel argument. *Using 0 or 1 or False or True does not work,
> >> as it is not a normal boolean.

>
> >> Could someone demonstrate for me how to call the _Exit event of a
> >> textbox?

>
> >> Thank you!

>
> >>SMS- Hide quoted text -

>
> - Show quoted text -


 
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
Calling Button click event from Form initialise event? noname Microsoft Excel Programming 2 10th Sep 2010 11:09 PM
RE: Calling Click Event from another Event GB Microsoft Access VBA Modules 0 2nd Sep 2009 01:07 PM
Calling Web Service in DragDrop event causes event to be fired multipletimes Vincent Mouton Microsoft Dot NET Framework Forms 0 18th Mar 2005 07:28 PM
Calling Event (sending Datatable) in Timer event problem! Anders Microsoft C# .NET 2 20th Dec 2004 06:21 PM
Server Side button calling page_load before calling it's own click event. Ryan Ternier Microsoft ASP .NET 4 29th Jul 2004 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:14 PM.