Solved

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

Posted on 2008-06-16
5
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Mailbox Overload?
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 …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

615 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