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

Hi VB Bugs...

I created a userform with textboxes to facilitate data entry on Excel
spreadsheet. I validated the textboxes to display a message box if
empty.
Userform automatically appears when file is open.
However, if I decide not to input data on userform & wish to
CANCEL(unload userform), a message box still appears.
How can I bypass validation for textboxes and proceed to CANCEL form??

Thanks and will validate your sugguestions!!
Myrna

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Bypass Textbox Validation

I assume you're running your validation routines from Sub
UserForm_QueryClose. If so, check the value of the CloseMode argument that
is passed to it. If it's 0 then the "x" was used to close the form. If
Unload caused it to close the value is 1.

--
Jim Rech
Excel MVP
"Myrna Rodriguez" wrote in message
...
| Hi VB Bugs...
|
| I created a userform with textboxes to facilitate data entry on Excel
| spreadsheet. I validated the textboxes to display a message box if
| empty.
| Userform automatically appears when file is open.
| However, if I decide not to input data on userform & wish to
| CANCEL(unload userform), a message box still appears.
| How can I bypass validation for textboxes and proceed to CANCEL form??
|
| Thanks and will validate your sugguestions!!
| Myrna
|
| *** Sent via Devdex http://www.devdex.com ***
| Don't just participate in USENET...get rewarded for it!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Bypass Textbox Validation


Hi...

This is the code I am currently using to validate textbox.

Private Sub txtfast_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'display msgbox if textbox fast is empty
If txtfast.Text = "" Then
MsgBox "Enter FAST File"
Cancel = True
End If
End Sub

**The message box appears successfully when empty, but when I close
userform by click on "X" the message box pops up. I would like to Cancel
userform even if textbox is empty.

Thanks,
Myrna





*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bypass Textbox Validation

Myrna Rodriguez,

Try using a close command button on your userform.


Private Sub CommandButton1_Click()
Unload UserForm1
End Sub

HTH

Charle

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Bypass Textbox Validation

This is the code I am currently using to validate textbox

You might defer all your validating until the user tries to close the form.

Or you could consider this approach:

Dim ExitMode As Boolean

Private Sub UserForm_Activate()
ExitMode = False
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ExitMode = True
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If ExitMode = False Then
If TextBox1.Text = "" Then MsgBox "Warning"
End If
End Sub

--
Jim Rech
Excel MVP
"Myrna Rodriguez" wrote in message
...

Hi...

This is the code I am currently using to validate textbox.

Private Sub txtfast_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'display msgbox if textbox fast is empty
If txtfast.Text = "" Then
MsgBox "Enter FAST File"
Cancel = True
End If
End Sub

**The message box appears successfully when empty, but when I close
userform by click on "X" the message box pops up. I would like to Cancel
userform even if textbox is empty.

Thanks,
Myrna





*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Textbox validation TUNGANA KURMA RAJU Excel Discussion (Misc queries) 5 May 8th 09 11:15 PM
Textbox validation phreud[_17_] Excel Programming 6 June 27th 04 07:49 PM
textbox validation Beginner[_2_] Excel Programming 1 April 7th 04 07:46 PM
putting validation to TextBox in the userform salihyil[_6_] Excel Programming 1 February 26th 04 12:10 PM
Userform Textbox in Password Validation golf4 Excel Programming 3 July 28th 03 02:27 PM


All times are GMT +1. The time now is 07:20 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"