Solved

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

Posted on 2008-06-16
5
165 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
5 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Read this checklist to learn more about the 15 things you should never include in an email signature.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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…

809 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