Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Userform_Terminate

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gojavid - 05 Jun 2007 14:54 GMT
I have a form that I'm trying to add some code to that will require a
combobox to be filled in before it is closed.

The problem:

The code I've put under the userform_terminate shows the form, but it
won't close when combobox event has been completed.  It doesn't seem
to be calling the combobox_change event after the terminate button has
been pushed.

The code:

Private Sub UserForm_Terminate()
MsgBox ("Please select an instrument.  This step is required to
continue.")
fmr_instrumentselect.show
End Sub

Any ideas?
Bob Phillips - 05 Jun 2007 16:06 GMT
You can't use Terminate, the form is shutting down at this point. Add an OK
button and check it in there.

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I have a form that I'm trying to add some code to that will require a
> combobox to be filled in before it is closed.
[quoted text clipped - 15 lines]
>
> Any ideas?
Gojavid - 05 Jun 2007 16:17 GMT
> You can't use Terminate, the form is shutting down at this point. Add an OK
> button and check it in there.

Thanks for the advice.  I have the form open as part of the
workbook_open so I just added the code to that.
Dave Peterson - 05 Jun 2007 16:13 GMT
Maybe you could change the Cancel's button .takefocusonclick property to false.

> I have a form that I'm trying to add some code to that will require a
> combobox to be filled in before it is closed.
[quoted text clipped - 15 lines]
>
> Any ideas?

Signature

Dave Peterson

Gojavid - 05 Jun 2007 16:34 GMT
I'm interested...  How do I refer to the cancel button?
Dave Peterson - 05 Jun 2007 16:45 GMT
I put a textbox and two commandbuttons on a small userform.  This was the code
behind it:

Option Explicit
Private Sub CommandButton1_Click()
   Unload Me
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
   MsgBox "trying to exit"
   'and never let them (just for testing)
   Cancel = True
End Sub
Private Sub UserForm_Initialize()
   With Me.CommandButton1
       .Caption = "Cancel"
       .TakeFocusOnClick = False
   End With
   
   With Me.CommandButton2
       .Caption = "Ok"
   End With
End Sub

> I'm interested...  How do I refer to the cancel button?

Signature

Dave Peterson

Dave Peterson - 05 Jun 2007 16:52 GMT
Ps.

I figured your code would have at least two buttons on it.

One that has a caption of "ok" (or something like that).

And one that has a caption of "Cancel") (or equivalent).

> I put a textbox and two commandbuttons on a small userform.  This was the code
> behind it:
[quoted text clipped - 24 lines]
>
> Dave Peterson

Signature

Dave Peterson

Gojavid - 06 Jun 2007 15:16 GMT
It works great.  Thanks for the advice!

> Ps.
>
[quoted text clipped - 36 lines]
>
> Dave Peterson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.