PC Review


Reply
Thread Tools Rate Thread

Desable "Cancel" event

 
 
=?Utf-8?B?THVpc0U=?=
Guest
Posts: n/a
 
      28th Aug 2007
I’ve been trying to write a routine to prevent empty textboxes. I’m using the
TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I
disabled the close button and using a CommandButton instead; if the user
doesn’t make any entry at all, it’ll still trigger the error message when
closing the form. Is there a way around it. Can I cancel the “cancel event”
while closing the form from the CommandButton?

I can’t retain the focus on the control. I also tried the BeforeUpdate event
but didn’t get the expected results. Do you know of any good source of
related documentation?




 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      29th Aug 2007
Public bBlockEvents as Boolean

Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
if bBlockEvents then exit sub


End sub

Sub CmdExit_Click()
bBlockEvents = True


end Sub

so use a public variable in the userform module to indicate your intention
and exercise control.

--
Regards,
Tom Ogilvy


"LuisE" wrote:

> I’ve been trying to write a routine to prevent empty textboxes. I’m using the
> TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I
> disabled the close button and using a CommandButton instead; if the user
> doesn’t make any entry at all, it’ll still trigger the error message when
> closing the form. Is there a way around it. Can I cancel the “cancel event”
> while closing the form from the CommandButton?
>
> I can’t retain the focus on the control. I also tried the BeforeUpdate event
> but didn’t get the expected results. Do you know of any good source of
> related documentation?
>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?SGFsaW0=?=
Guest
Posts: n/a
 
      29th Aug 2007
Hi,

Just adding without ignoring Tom's code:

Private Sub CommandButton1_Click()
If TextBox1 = "" Then TextBox1.SetFocus: Exit Sub
Unload Me
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 = "" Then Cancel = True
End Sub


--
Regards,

Halim



"LuisE" wrote:

> I’ve been trying to write a routine to prevent empty textboxes. I’m using the
> TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I
> disabled the close button and using a CommandButton instead; if the user
> doesn’t make any entry at all, it’ll still trigger the error message when
> closing the form. Is there a way around it. Can I cancel the “cancel event”
> while closing the form from the CommandButton?
>
> I can’t retain the focus on the control. I also tried the BeforeUpdate event
> but didn’t get the expected results. Do you know of any good source of
> related documentation?
>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?THVpc0U=?=
Guest
Posts: n/a
 
      1st Sep 2007
Once Again Thank you

"Tom Ogilvy" wrote:

> Public bBlockEvents as Boolean
>
> Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
> if bBlockEvents then exit sub
>
>
> End sub
>
> Sub CmdExit_Click()
> bBlockEvents = True
>
>
> end Sub
>
> so use a public variable in the userform module to indicate your intention
> and exercise control.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "LuisE" wrote:
>
> > I’ve been trying to write a routine to prevent empty textboxes. I’m using the
> > TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I
> > disabled the close button and using a CommandButton instead; if the user
> > doesn’t make any entry at all, it’ll still trigger the error message when
> > closing the form. Is there a way around it. Can I cancel the “cancel event”
> > while closing the form from the CommandButton?
> >
> > I can’t retain the focus on the control. I also tried the BeforeUpdate event
> > but didn’t get the expected results. Do you know of any good source of
> > related documentation?
> >
> >
> >
> >

 
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
Eliminate "Cancel" Button on Save/Close Event Excel Monkey Microsoft Excel Programming 2 18th Apr 2009 02:31 AM
I can't "Open" a downloaded template. Only "Save" and "Cancel" Dave Microsoft Word Document Management 1 4th Apr 2008 02:28 PM
How to Cancel a "non cancellable" Event Verde Microsoft C# .NET 5 15th Sep 2005 05:53 PM
Cancel event "not in list" if before update is not true =?Utf-8?B?RXJpaw==?= Microsoft Access VBA Modules 5 26th Feb 2004 06:33 AM
Desable "Shift" on Access Maria Joao Microsoft Access Security 3 19th Sep 2003 09:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 PM.