472,362 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,362 software developers and data experts.

Strange behaviour of Form_Activate

Ian
Hi everyone,

I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.

After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:

Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End

This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.

Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.

Any help / advice on this issue would be gratefully received!

Thanks,

Ian

Sep 5 '06 #1
5 3020
Hi Ian,

You have to understand that to close the form it must become the active
form, albeit for just a blink of an eye. So when your routine tries to
close the form it immediatley becomes active, and the Form_Activate
routine starts running. Before that finishes you try and close the
form, you can't and the routine stops, then the Form_Activate finishes.

Hope that this helps,

Nick

Ian wrote:
Hi everyone,

I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.

After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:

Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End

This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.

Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.

Any help / advice on this issue would be gratefully received!

Thanks,

Ian
Sep 5 '06 #2
Ian
That explanation makes sense to me, but I then don't see why my Form
Close event would then fire a second time?

Nick 'The database Guy' wrote:
Hi Ian,

You have to understand that to close the form it must become the active
form, albeit for just a blink of an eye. So when your routine tries to
close the form it immediatley becomes active, and the Form_Activate
routine starts running. Before that finishes you try and close the
form, you can't and the routine stops, then the Form_Activate finishes.

Hope that this helps,

Nick

Ian wrote:
Hi everyone,

I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.

After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:

Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End

This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.

Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.

Any help / advice on this issue would be gratefully received!

Thanks,

Ian
Sep 5 '06 #3
I'm open to correction if anyone else knows better than me, but I would
have said that the event fires a second time because it is getting the
focus back from the code that was trying to close the form.

Nick

Ian wrote:
That explanation makes sense to me, but I then don't see why my Form
Close event would then fire a second time?

Nick 'The database Guy' wrote:
Hi Ian,

You have to understand that to close the form it must become the active
form, albeit for just a blink of an eye. So when your routine tries to
close the form it immediatley becomes active, and the Form_Activate
routine starts running. Before that finishes you try and close the
form, you can't and the routine stops, then the Form_Activate finishes.

Hope that this helps,

Nick

Ian wrote:
Hi everyone,
>
I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.
>
After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:
>
Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End
>
This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.
>
Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.
>
Any help / advice on this issue would be gratefully received!
>
Thanks,
>
Ian
Sep 5 '06 #4
Ian
Hi Nick,

Thanks for keeping going with this one for me!

I also thought that it might be restarting from where it left off after
the activate call ran, but the text output to my immediate window
suggests that the close event is not restarting but running a second
time?

Thanks again,

Ian

Nick 'The database Guy' wrote:
I'm open to correction if anyone else knows better than me, but I would
have said that the event fires a second time because it is getting the
focus back from the code that was trying to close the form.

Nick

Ian wrote:
That explanation makes sense to me, but I then don't see why my Form
Close event would then fire a second time?

Nick 'The database Guy' wrote:
Hi Ian,
>
You have to understand that to close the form it must become the active
form, albeit for just a blink of an eye. So when your routine tries to
close the form it immediatley becomes active, and the Form_Activate
routine starts running. Before that finishes you try and close the
form, you can't and the routine stops, then the Form_Activate finishes.
>
Hope that this helps,
>
Nick
>
Ian wrote:
Hi everyone,

I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.

After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:

Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End

This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.

Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.

Any help / advice on this issue would be gratefully received!

Thanks,

Ian
Sep 5 '06 #5
Like I said the code starts closing the form, then the form gets the
focus, the OnActivate starts running, the form cannot be closed because
the OnActivate is running, the form loses the focus as the code that
was trying to close it finishes, then the form receives teh focus again
and the OnActivate run again.

If I were you I would put my code behind some other event than
OnActivate.

Good luck

Nick
Ian wrote:
Hi Nick,

Thanks for keeping going with this one for me!

I also thought that it might be restarting from where it left off after
the activate call ran, but the text output to my immediate window
suggests that the close event is not restarting but running a second
time?

Thanks again,

Ian

Nick 'The database Guy' wrote:
I'm open to correction if anyone else knows better than me, but I would
have said that the event fires a second time because it is getting the
focus back from the code that was trying to close the form.

Nick

Ian wrote:
That explanation makes sense to me, but I then don't see why my Form
Close event would then fire a second time?
>
Nick 'The database Guy' wrote:
>
Hi Ian,

You have to understand that to close the form it must become the active
form, albeit for just a blink of an eye. So when your routine tries to
close the form it immediatley becomes active, and the Form_Activate
routine starts running. Before that finishes you try and close the
form, you can't and the routine stops, then the Form_Activate finishes.

Hope that this helps,

Nick

Ian wrote:
Hi everyone,
>
I have found some bizarre (to me...!) behaviour of the Form_Activate
function. I have a form which has a button control used to close the
form and a subform with a datasheet view showing a list of jobs from
the database. When the main form loses focus and the user clicks the
'Close' button, I kept receiving error 2585 (This action cannot be
carried out whilst processing a form or report event). This was tracked
down to erroring when trying to carry out the DoCmd.Close acForm call.
>
After some investigation, I have tracked the problem down to some
strange interactions between the forms Activate event and the click
event on the button in question. I have used a combination of some code
to stop the error from occuring and the the immediate window to test
the code flow, and have discovered the following:
>
Activate Start
Form Close Start
Form Close Handled End
Activate End
Form Close Start
Form Close End
>
This is the output from the immediate window after placing a text
output at the start, end of the Activate event and the start, end of
the button event code. The 'Form Close Handled End' occurs when my code
to stop error 2585 is used. It appears to suggest that the Activate
event fires, then the Form Close subroutine starts immediately after.
This then is handled and quit without closing the form by my new code.
The Activate event then gets round to finishing and the form close
event runs a second time.
>
Although I have now created some code to work around this issue, I am
intrigued as to whether this is a bug that I have stumbled across or I
just don't quite understand the way the two event interact. It seems a
very strange problem.
>
Any help / advice on this issue would be gratefully received!
>
Thanks,
>
Ian
Sep 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
2
by: Adam Honek | last post by:
In VB6 and earlier we had a form_activate() event whereby it always fired every time the form gained was focussed. In VB.net I don't see it and we have a _activate() event. What event would I...
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
20
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.