Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
172 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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