[AccessD] Close a form during the Activate event

Benson, William (GE Global Research, consultant) Benson at ge.com
Mon Dec 5 22:04:22 CST 2011


Not a difficult task... but not something I want to resort to. I gave up
:-(

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart
McLachlan
Sent: Monday, December 05, 2011 10:22 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Close a form during the Activate event

You can set me.Visible = False instead of closing the form.

How to garbage collect and subsequently close the hidden form is left as
an exercise for the reader. :-)

--
Stuart

On 5 Dec 2011 at 21:41, Benson, William (GE Global Re wrote:

> Sorry, I cannot make my statement about "dangerous to use" very clear 
> at this time. Essentially, if the form is open and a certain value has

> changed (say, for example, a user's privileges have changed from one 
> class to another) then I do not want them able to see the form that 
> they had been looking at. So it was on the activate event that this 
> was to be checked for.
> 
> That is not the exact condition, it is a representative example.
> 
> To answer Charlotte's question:
> 
> "this action cannot be carried out while processing a form or report 
> event"
> 
> Here is a sample of code you can put in a form that is already opened:
> 
> Private Sub Form_Activate()
> If 1 = 2 Then DoCmd.Close acForm, Me.Name End Sub
> 
> 
> Launch the form, then deactivate it by opening a different form.
> 
> Change the code to
> If 1 = 1 Then DoCmd.Close acForm, Me.Name
> 
> Click back on the first form, you will get this error message.
> 
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list