473,769 Members | 6,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is Access consistent with the order of events when opening a form from within a procedure?

MLH
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?
Nov 12 '05 #1
9 3113
MLH
Excuse me for leaving off the specific MyForm2
events I was concerned with, they are...
OPEN
LOAD
RESIZE
ACTIVATE
CURRENT

xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xx
On Mon, 22 Dec 2003 10:49:53 -0500, MLH <CR**@NorthStat e.net> wrote:
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #2
On Mon, 22 Dec 2003 10:49:53 -0500, MLH <CR**@NorthStat e.net> wrote:

The use of DoEvents would throw things off.
Also setting Cancel to True in Form_Open.
Perhaps also resizing your form in Form_Open or Form_Load.

-Tom.

If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #3
WFICT, no, there is no case where those events would not all fire prior to the
MsgBox call. However, writing code that depends on sequence is generally good
to avoid if you can think of an easy way to avoid it, because such code tends
to be more modular and cleaner anyway, and because it's bossible that new
versions of the software or new code of yours in the form itself could cause
breakage of the logic.

Example. Occasionally, you find something in Access that you need to do when
a form opens that does not work right when attempted from either the Open or
Load events, so you set up a 1ms timer, and call it from there. Now, even
though Access would perform as expected, you have still broken the calling
code by moving the logic.

Of course, using the timer event, then, is another thing you want to try to
avoid for musch the same reason, but the point is that if you can avoid
strenuous expectations by any part of the code, you have more slack elsewhere
if you need it.

On Mon, 22 Dec 2003 10:57:07 -0500, MLH <CR**@NorthStat e.net> wrote:
Excuse me for leaving off the specific MyForm2
events I was concerned with, they are...
OPEN
LOAD
RESIZE
ACTIVATE
CURRENT

xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxx
On Mon, 22 Dec 2003 10:49:53 -0500, MLH <CR**@NorthStat e.net> wrote:
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #4
CR**@NorthState .net (MLH) wrote in
<4m************ *************** *****@4ax.com>:
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Successive lines of code executed asynchronously, so, the
MessageBox could fire before all the events of the form opening
would fire.

A kludgy way to force it would be:

DoCmd OpenForm "MyForm2", , , , , acDialog
[in the form's Activate event, set Me.Visible = False]
MsgBox "I opened MyForm2"
Forms!MyForm2.V isible = True

Of course, at that point, it's still a dialog form.

And I can't guarantee that this will always work.

If you really want code to execute only after a form has finished
opening, the code needs to be in the last relevant event of the
form. And, even then, you can't control it for sure, as other
things can intervene.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #5
MLH
Interesting!
xxxxxxxxxxxxxxx xxx
On Mon, 22 Dec 2003 09:12:22 -0700, Tom van Stiphout
<to*****@no.spa m.cox.net> wrote:
On Mon, 22 Dec 2003 10:49:53 -0500, MLH <CR**@NorthStat e.net> wrote:

The use of DoEvents would throw things off.
Also setting Cancel to True in Form_Open.
Perhaps also resizing your form in Form_Open or Form_Load.

-Tom.

If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #6
On Mon, 22 Dec 2003 18:19:26 GMT, dX********@bway .net.invalid (David W.
Fenton) wrote:
CR**@NorthStat e.net (MLH) wrote in
<4m*********** *************** ******@4ax.com> :
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?
Successive lines of code executed asynchronously, so, the
MessageBox could fire before all the events of the form opening
would fire.


Access does many things aynchronously, but I have yet to notice a case when
the next statement after an OpenForm could fire before all of the initial form
open events (not that I advocate relying on this).

One certainly must be careful with things like expecting a table or report
export to be completed before trying to do something with the resulting file.
In this case, adding a singe DoEvents call will force VBA to wait until the
export completes.
A kludgy way to force it would be:

DoCmd OpenForm "MyForm2", , , , , acDialog
[in the form's Activate event, set Me.Visible = False]
MsgBox "I opened MyForm2"
Forms!MyForm2.V isible = True

Of course, at that point, it's still a dialog form.

And I can't guarantee that this will always work.

If you really want code to execute only after a form has finished
opening, the code needs to be in the last relevant event of the
form. And, even then, you can't control it for sure, as other
things can intervene.


I generally have good luck using the On Current event handler for these cases,
and making sure one of the controls' value property can be accessed without
error. On Current is usually called once or twice before the recordset is
loaded, but once the Value properties are accessible, everything is ready to
roll.
Nov 12 '05 #7
TC
The others have said no, in the absence of a doevents, the open/load etc.
events will fire before you get to the messagebox. But IMO, this is not
because ms designed it that way. It is a (probably not deliberate)
side-effect of the fact that VBA is single-threaded. The thread in question
is busy opening the called form; there is just no other thread available for
the msgbox. But if the called form does a doevents, that thread stops, & all
sorts of curious race conditions can happen then.

HTH,
TC
"MLH" <CR**@NorthStat e.net> wrote in message
news:4m******** *************** *********@4ax.c om...
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?

Nov 12 '05 #8
MLH
Now that's what I'm talkin' about. I never put my finger
on it but, deja vu, I seem to remember encountering
strange effects I could never put my finger on. I couldn't
replicate them (weary from the work-around battle) and
I ended up forgetting about the situation. I'm going to
do some testing around your comments... Thx.
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxx
On Tue, 23 Dec 2003 14:49:37 +1200, "TC" <a@b.c.d> wrote:
The others have said no, in the absence of a doevents, the open/load etc.
events will fire before you get to the messagebox. But IMO, this is not
because ms designed it that way. It is a (probably not deliberate)
side-effect of the fact that VBA is single-threaded. The thread in question
is busy opening the called form; there is just no other thread available for
the msgbox. But if the called form does a doevents, that thread stops, & all
sorts of curious race conditions can happen then.

HTH,
TC
"MLH" <CR**@NorthStat e.net> wrote in message
news:4m******* *************** **********@4ax. com...
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #9
On Tue, 23 Dec 2003 21:34:45 -0500, MLH <CR**@NorthStat e.net> wrote:

Doevents should be used very sparingly, and judiciously.

I once was called to a job where the app was doing "weird
unreproducible things". Within an hour it worked again, after I did a
global find & replace for DoEvents with 'DoEvents (commenting out
several dozen occurrences).
I spent a bit more time inspecting each one, and eventually
uncommented one or two.

-Tom.

Now that's what I'm talkin' about. I never put my finger
on it but, deja vu, I seem to remember encountering
strange effects I could never put my finger on. I couldn't
replicate them (weary from the work-around battle) and
I ended up forgetting about the situation. I'm going to
do some testing around your comments... Thx.
xxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxx
On Tue, 23 Dec 2003 14:49:37 +1200, "TC" <a@b.c.d> wrote:
The others have said no, in the absence of a doevents, the open/load etc.
events will fire before you get to the messagebox. But IMO, this is not
because ms designed it that way. It is a (probably not deliberate)
side-effect of the fact that VBA is single-threaded. The thread in question
is busy opening the called form; there is just no other thread available for
the msgbox. But if the called form does a doevents, that thread stops, & all
sorts of curious race conditions can happen then.

HTH,
TC
"MLH" <CR**@NorthStat e.net> wrote in message
news:4m****** *************** ***********@4ax .com...
If you have these lines in code on MyForm1...

DoCmd OpenForm "MyForm2`"
MsgBox "I opened MyForm2"

Is it #ALWAYS# true that all form events
on MyForm2 will occur before the MsgBox
statement in MyForm1 is processed?

Is there ever an exception that might create
a race condition in which the MsgBox line
would be processed before one or more of
the MyForm2 events?


Nov 12 '05 #10

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

Similar topics

6
4753
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
49
14354
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The application is relatively big: around 200 tables, 200 forms and sub-forms, 150 queries and 150 repports, 5GB of data (SQL Server 2000), 40 users. I'm wondering what are the disadvantages of using Access as front-end? Other that it's not...
20
3347
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to speed. I like books with practical exercises, and also with test questions (like cert books) *2*
0
1871
by: jphelan | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was pattern after the same form used in the MS template, "Event Management.mdb" application that is downloaded from the MS Template Gallery on their website. I narrowed down the problem to the Control Source in the, "Attendees_Subform using the...
8
10770
by: lauren quantrell | last post by:
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like: Me.paramaters = "@SomeColumn = 22)" Me.recordsource = "dbo.sproc123" But I can't do this in a report as it will prompt me for the parameters, even though they seem to be defined ahead of the recordsource. I have worked around this by opening reports to a bogus recordsource
5
2689
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers, you will have built up a substantial inventory of code in that time. And if you've been following...
13
3998
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate button "Unexpected Error":3251 operation is not supported for this type of object.The demo cd has two databases, one is called inventory and the other just has the tables for the design called inventory data. When you run inventory the database works...
1
1636
by: KRSharp | last post by:
I am new to Access, so bear with me. I think this is possible, but I am not sure how to get this going. I am trying to develop a database that will allow me to create a manufacturing schedule based on our customer demand and our capacity in minutes. I have created a table (Demand) that will take our customer demand, blow through our Bill of Materials and will leave me with a set of demand that gives me a production work center, the...
4
12441
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
9587
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.