LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default unload userform from within one of that form's beforeupdate events?

I'm still pretty much a novice excel programmer; I've been stumped
with the following question for a day, and I haven't seen in addressed
in the groups. Please forgive me if it has.

I've got a userform with a control called "TextBoxNoOfFilters". In a
simplified version of the problem, I need to make sure that a number
is entered, and that that number is NOT 2. If the user does enter 2,
I'd like to immediately indicate this elsewhere in the workbook (with
textboxes) and then exit the userform.

When I call the Unload Userform command, it works, but the unload
process seems to call the BeforeUpdate procedure again. Therefore, if
the user enters 2 and confirms it, the userform disappears and then
they get another msgbox asking them to confirm their entry.

I can't figure out why the unload calls the beforeupdate again, or how
to avoid that re-call.

A sketch of the code follows. Any thoughts would be most appreciated.

Thanks,
Andrew H.


Private Sub TextBoxNoOfFilters_BeforeUpdate(ByVal Cancel As
MSForms.ReturnBoolean)

If IsNumeric(TextBoxNoOfFilters) Then
If TextBoxNoOfFilters = 2 Then

msg = "Are you sure you want to enter 2?"
response = MsgBox(prompt:=msg, _
Buttons:=vbQuestion + vbYesNo, _
Title:="Confirm 2 Filters")

If response = vbYes Then
msg = "New warning message goes here"
MsgBox prompt:=msg, Buttons:=vbExclamation
'call a sub to put some text boxes on the worksheets
Unload Userform
End If

End if
Else
msg = "Please enter a number"
MsgBox prompt:=msg, Buttons:=vbExclamation
Cancel = True
TextBoxNoOfFilters = TextBoxNoOfFilters.BoundValue
End Sub
 
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
How can I expose the TextBox BeforeUpdate event to my user class? bereid Excel Discussion (Misc queries) 0 November 30th 05 05:00 PM
IeTimer events not working in modeless Userform? Ed[_18_] Excel Programming 0 August 3rd 04 04:21 PM
BeforeUpdate and Cancel Brad Excel Programming 0 May 10th 04 09:06 PM
BeforeUpdate event for Combo box Brad Excel Programming 2 May 7th 04 06:22 PM
UserForm Events Nigel[_6_] Excel Programming 1 February 22nd 04 12:19 PM


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