Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hitting the 'x' to escape- how to control what happens when this button is pressed

Posted on 2008-06-16
5
Medium Priority
?
174 Views
Last Modified: 2010-04-08
Hi
I have created forms which use data imported from an access database and placed in comboboxes.
I only input the data once, upon opening outlook, as it takes time to load. The data is stored in a string and as the value of the comboboxes.
If a user exits a form using the cancel button ie userform.hide, then the comboboxes retain their list values for the next time they are opened, as desired.
However, if they exit the forms using the 'x' at the top right hand side of the form, the values are lost.

How can I combat this?

Thank you.
0
Comment
Question by:kafrin_1
  • 2
3 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 21799159
Not sure what you can do to interrupt the flow of the exit directly ... the form terminate event still runs to completion, but when opeing your form you could use a global var to store the string ... checking for null on form open to establish if the data needs to be initialised.

In a normal module define a var as public testmemoryitem as string then test for "" on form open initialising the data if so.

Chris

Chris
0
 

Accepted Solution

by:
kafrin_1 earned 0 total points
ID: 21800079
Thanks for the reply.

I found the following code elsewhere on the web and it does the trick, when added to the bottom of the code within each of my forms:

Private Sub UserForm_QueryClose(Cancel As Integer, _
    CloseMode As Integer)
     If CloseMode = vbFormControlMenu Then Cancel = True
     Call UserForm9.Hide
    'End If
   
   
End Sub

thanks for the reply.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 21800193
Well found ... I'll have to remember it!

Chris
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question