Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Cancel button to bypass MsgBox

hi VB addicts!!
hope all bugs are conquered...

i created a userform in Excel.
I validated a textbox when empty to trigger MsgBox.
However, when I wish to cancel userform...MsgBox displays
not allowing to cancel.
What can I do bypass MsgBox when cancelling userform entirely??

My code:
'textbox FAST
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

'Cancel Button
Private Sub cmdcancel_Click()
'cancel userform1
Unload UserForm1
End Sub


thanks in advance & have a happy day!!
myrna

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Cancel button to bypass MsgBox

Mhm... why don't you validate the txtfast in the "OK" button instead ?

--
Regards

Juan Pablo González

"Myrna Rodriguez" wrote in message
...
hi VB addicts!!
hope all bugs are conquered...

i created a userform in Excel.
I validated a textbox when empty to trigger MsgBox.
However, when I wish to cancel userform...MsgBox displays
not allowing to cancel.
What can I do bypass MsgBox when cancelling userform entirely??

My code:
'textbox FAST
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

'Cancel Button
Private Sub cmdcancel_Click()
'cancel userform1
Unload UserForm1
End Sub


thanks in advance & have a happy day!!
myrna

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cancel button to bypass MsgBox

Myrna,

Use a module scope variable, and set it to a value in the cancel procedure,
then test that in the exit routine. Something like

Dim fCancel As Boolean

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

'Cancel Button
Private Sub cmdcancel_Click()
'cancel userform1
fCancel = True
Unload UserForm1
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Myrna Rodriguez" wrote in message
...
hi VB addicts!!
hope all bugs are conquered...

i created a userform in Excel.
I validated a textbox when empty to trigger MsgBox.
However, when I wish to cancel userform...MsgBox displays
not allowing to cancel.
What can I do bypass MsgBox when cancelling userform entirely??

My code:
'textbox FAST
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

'Cancel Button
Private Sub cmdcancel_Click()
'cancel userform1
Unload UserForm1
End Sub


thanks in advance & have a happy day!!
myrna

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Cancel button to bypass MsgBox

I validated textboxes in command button OK.
When I Cancel, Msgbox appears and not letting me trigger
Cancel event. I used the code, but no luck...thanks Mr. Bob
Any other suggestion??
thanks...myrna



*** Sent via Developersdex http://www.developersdex.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
msgbox cancel? sycsummit Excel Discussion (Misc queries) 2 February 11th 09 04:37 PM
Inputbox or msgbox critical + Cancel Syrus the Virus[_18_] Excel Programming 2 March 2nd 04 01:28 PM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM
Cancel buttons in Msgbox Patrick Molloy Excel Programming 0 September 19th 03 07:59 AM
Button To Cancel Macro Bill Lunney Excel Programming 0 July 16th 03 10:27 PM


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

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"