Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Textbox validation | Excel Discussion (Misc queries) | |||
Textbox validation | Excel Programming | |||
textbox validation | Excel Programming | |||
putting validation to TextBox in the userform | Excel Programming | |||
Userform Textbox in Password Validation | Excel Programming |