Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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 …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now