DoEvents and Execution

I'm using AC2003.  I have FormA which has two subform controls on it which do 
not have a SourceObject assigned to them.  I do that in the form_open event, 
see below.  What I'm trying to do is to open a simple OneMomentPlease form 
that has several colored labels used to indicate progress.  As I understand 
it, a DoEvents statement should force all statements prior to it to execute 
before any following statements to execute.  However, it's not working that 
way.  When FormA is opened it runs through all statements.  Each sourceobject 
contains a fairly complex chart and takes 3-5 seconds to open each one.  I 
want to let users know that the system is working and not waiting for them.

Any help would be appreciated.


Private Sub Form_Open(Cancel As Integer)
    Me.Child1.SourceObject = "chartcarbs"
    DoCmd.OpenForm "OneMomentPlease", acNormal, , , acFormEdit
    Forms!OneMomentPlease.Form!Label5.Visible = True
    DoCmd.RepaintObject acForm, "OneMomentPlease"
    DoEvents
    Me.Child2.SourceObject = "chartcalories"
    Forms!OneMomentPlease.Form!Label6.Visible = True
    DoCmd.RepaintObject acForm, "OneMomentPlease"
    DoCmd.Close acForm, "OneMomentPlease"
    DoEvents
End Sub

0
Utf
3/24/2010 7:14:06 PM
access 16762 articles. 3 followers. Follow

4 Replies
2229 Views

Similar Articles

[PageSpeed] 22

DoEvents allows Windows to do things. It passes control to the OS and not the 
database.
-- 
Jerry Whittle, Microsoft Access MVP 
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"PeterM" wrote:

> I'm using AC2003.  I have FormA which has two subform controls on it which do 
> not have a SourceObject assigned to them.  I do that in the form_open event, 
> see below.  What I'm trying to do is to open a simple OneMomentPlease form 
> that has several colored labels used to indicate progress.  As I understand 
> it, a DoEvents statement should force all statements prior to it to execute 
> before any following statements to execute.  However, it's not working that 
> way.  When FormA is opened it runs through all statements.  Each sourceobject 
> contains a fairly complex chart and takes 3-5 seconds to open each one.  I 
> want to let users know that the system is working and not waiting for them.
> 
> Any help would be appreciated.
> 
> 
> Private Sub Form_Open(Cancel As Integer)
>     Me.Child1.SourceObject = "chartcarbs"
>     DoCmd.OpenForm "OneMomentPlease", acNormal, , , acFormEdit
>     Forms!OneMomentPlease.Form!Label5.Visible = True
>     DoCmd.RepaintObject acForm, "OneMomentPlease"
>     DoEvents
>     Me.Child2.SourceObject = "chartcalories"
>     Forms!OneMomentPlease.Form!Label6.Visible = True
>     DoCmd.RepaintObject acForm, "OneMomentPlease"
>     DoCmd.Close acForm, "OneMomentPlease"
>     DoEvents
> End Sub
> 
0
Utf
3/24/2010 8:36:01 PM
Is there any way to do what I need?

"Jerry Whittle" wrote:

> DoEvents allows Windows to do things. It passes control to the OS and not the 
> database.
> -- 
> Jerry Whittle, Microsoft Access MVP 
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> 
> 
> "PeterM" wrote:
> 
> > I'm using AC2003.  I have FormA which has two subform controls on it which do 
> > not have a SourceObject assigned to them.  I do that in the form_open event, 
> > see below.  What I'm trying to do is to open a simple OneMomentPlease form 
> > that has several colored labels used to indicate progress.  As I understand 
> > it, a DoEvents statement should force all statements prior to it to execute 
> > before any following statements to execute.  However, it's not working that 
> > way.  When FormA is opened it runs through all statements.  Each sourceobject 
> > contains a fairly complex chart and takes 3-5 seconds to open each one.  I 
> > want to let users know that the system is working and not waiting for them.
> > 
> > Any help would be appreciated.
> > 
> > 
> > Private Sub Form_Open(Cancel As Integer)
> >     Me.Child1.SourceObject = "chartcarbs"
> >     DoCmd.OpenForm "OneMomentPlease", acNormal, , , acFormEdit
> >     Forms!OneMomentPlease.Form!Label5.Visible = True
> >     DoCmd.RepaintObject acForm, "OneMomentPlease"
> >     DoEvents
> >     Me.Child2.SourceObject = "chartcalories"
> >     Forms!OneMomentPlease.Form!Label6.Visible = True
> >     DoCmd.RepaintObject acForm, "OneMomentPlease"
> >     DoCmd.Close acForm, "OneMomentPlease"
> >     DoEvents
> > End Sub
> > 
0
Utf
3/24/2010 8:42:01 PM
You could open a form setting both the Modal and PopUp properties to Yes.  
Then use this form's Timer event close the form in a few seconds. Modal and 
PopUp will block users from doing anything until the form closes.
-- 
Jerry Whittle, Microsoft Access MVP 
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"PeterM" wrote:

> Is there any way to do what I need?
> 
> "Jerry Whittle" wrote:
> 
> > DoEvents allows Windows to do things. It passes control to the OS and not the 
> > database.
> > -- 
> > Jerry Whittle, Microsoft Access MVP 
> > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> > 
> > 
> > "PeterM" wrote:
> > 
> > > I'm using AC2003.  I have FormA which has two subform controls on it which do 
> > > not have a SourceObject assigned to them.  I do that in the form_open event, 
> > > see below.  What I'm trying to do is to open a simple OneMomentPlease form 
> > > that has several colored labels used to indicate progress.  As I understand 
> > > it, a DoEvents statement should force all statements prior to it to execute 
> > > before any following statements to execute.  However, it's not working that 
> > > way.  When FormA is opened it runs through all statements.  Each sourceobject 
> > > contains a fairly complex chart and takes 3-5 seconds to open each one.  I 
> > > want to let users know that the system is working and not waiting for them.
> > > 
> > > Any help would be appreciated.
> > > 
> > > 
> > > Private Sub Form_Open(Cancel As Integer)
> > >     Me.Child1.SourceObject = "chartcarbs"
> > >     DoCmd.OpenForm "OneMomentPlease", acNormal, , , acFormEdit
> > >     Forms!OneMomentPlease.Form!Label5.Visible = True
> > >     DoCmd.RepaintObject acForm, "OneMomentPlease"
> > >     DoEvents
> > >     Me.Child2.SourceObject = "chartcalories"
> > >     Forms!OneMomentPlease.Form!Label6.Visible = True
> > >     DoCmd.RepaintObject acForm, "OneMomentPlease"
> > >     DoCmd.Close acForm, "OneMomentPlease"
> > >     DoEvents
> > > End Sub
> > > 
0
Utf
3/25/2010 2:16:01 PM
What you are doing should work.  I use that technique to update a progress bar 
on a form.

Here is the code I use and it works for me.  As you can see the code seems to 
parallel your code closely.


Public Function fHandleProgressMeter(strMessage As String, Optional 
rPercentage = 0)
'*******************************************
'Name:      fHandleProgressMeter (Function)
'Purpose:   Loads and updates frmProgressMessage to show progress in loops etc.
'           Calling function must close form when finished.
'Author:    John Spencer UMBC-CHPDM
'Date:      April 28, 2000, 12:04:04 PM
'Inputs:    strMessage - message to be displayed to user
'           -- strMessage - "Close" will close the form
'           rPercentage - 0 to 1 will display progress bar 0 to 100
'Output:
'*******************************************

    If IsLoaded("frmProgressMessage") = False Then
       DoCmd.OpenForm "frmProgressMessage", acNormal
    End If

    If strMessage = "Close" Then
       DoCmd.Close acForm, "frmProgressMessage"
    Else

       Forms!frmProgressmessage!lblMESSAGE.Caption = strMessage
       If rPercentage > 1.1 Then rPercentage = 1
       Forms!frmProgressmessage!shpProgressMeter.Width = rPercentage * 5 * 1440
       DoCmd.RepaintObject acForm, "FrmProgressMessage"
       DoEvents
    End If


End Function

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

PeterM wrote:
> Is there any way to do what I need?
> 
> "Jerry Whittle" wrote:
> 
>> DoEvents allows Windows to do things. It passes control to the OS and not the 
>> database.
>> -- 
>> Jerry Whittle, Microsoft Access MVP 
>> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>>
>>
>> "PeterM" wrote:
>>
>>> I'm using AC2003.  I have FormA which has two subform controls on it which do 
>>> not have a SourceObject assigned to them.  I do that in the form_open event, 
>>> see below.  What I'm trying to do is to open a simple OneMomentPlease form 
>>> that has several colored labels used to indicate progress.  As I understand 
>>> it, a DoEvents statement should force all statements prior to it to execute 
>>> before any following statements to execute.  However, it's not working that 
>>> way.  When FormA is opened it runs through all statements.  Each sourceobject 
>>> contains a fairly complex chart and takes 3-5 seconds to open each one.  I 
>>> want to let users know that the system is working and not waiting for them.
>>>
>>> Any help would be appreciated.
>>>
>>>
>>> Private Sub Form_Open(Cancel As Integer)
>>>     Me.Child1.SourceObject = "chartcarbs"
>>>     DoCmd.OpenForm "OneMomentPlease", acNormal, , , acFormEdit
>>>     Forms!OneMomentPlease.Form!Label5.Visible = True
>>>     DoCmd.RepaintObject acForm, "OneMomentPlease"
>>>     DoEvents
>>>     Me.Child2.SourceObject = "chartcalories"
>>>     Forms!OneMomentPlease.Form!Label6.Visible = True
>>>     DoCmd.RepaintObject acForm, "OneMomentPlease"
>>>     DoCmd.Close acForm, "OneMomentPlease"
>>>     DoEvents
>>> End Sub
>>>
0
John
3/25/2010 7:23:06 PM
Reply:

Similar Artilces:

Mem Usage increase while while executing dialog box
Dear All, Hope I have posted to the correct topic area. Need some help here. 1. I have created a simple dialog box using Visual Studio C++ 6.0, the dialog box contains an multiline read-only Edit Box, a Start Button and a Stop Button. 2. When the Start Button is clicked, the program will execute and the Edit Box will just print out the following text - "Line XX", where XX is the number 3. Problem is that when the program is executed and using Windows Task Manager to monitor the process, there is a high usage of Memory (ranges from 3636K to as high as 40000K). 4. Question ...

Server execution failed
Am trying to play WMV clips. I keep getting Server Execution Failed messages. What's the fix? Thanks. -- James Never mind. Fixed it by running a registry cleaner. Odd. -- James "James Ko" <iamwho@hawaii.rr.com> wrote in message news:uhbKodidKHA.6096@TK2MSFTNGP02.phx.gbl... > Am trying to play WMV clips. I keep getting Server Execution Failed > messages. What's the fix? Thanks. > > -- > James ...

Updating Form Field During Execution
I have a textbox field on a form in which I enter the number of times to execute a particular loop in my program. If I enter 2000, I would like for the field to change, maybe every 100 executions, to show how many remaining executions there are. I am changing the value (textbox.value = xx) after each 100 executions, but the field on the form does not refresh until all 2000 loops have been executed. Is there some way to accomplish this? -- Bill @ UAMS This is a userform? Try changing your value: me.textbox.value = clng(me.textbox.value) - 100 me.repaint BillCPA wrote: >...

Execute an executable program.
How can I in code (VB.NET 2008) execute another executable program ? Thanks :) On Mar 26, 11:21=A0am, "Mr. X." <nospam@nospam_please.com> wrote: > How can I in code (VB.NET 2008) execute another executable program ? > > Thanks :) Process.Start("path_of_exe") http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.as= px is what you want. HTH, Onur G=FCzel Am 26.03.2010 10:21, schrieb Mr. X.: > How can I in code (VB.NET 2008) execute another executable program ? 'System.Diagnostics.Process.Start' or &#...

Adding fields to table like LTP1.......LTPn after query execution
Hi The query UPDATE smallcapm INNER JOIN ppcsmlcap ON smallcapm.ScripCode = ppcsmlcap. ScripCode SET smallcapm.LTP7 = [ppcsmlcap].[ltp]; I am having a table smallcapm with fields LTP1,LTP2,LTP3........LTP30.By using above update query i am updating LTP1,LTP2,LTP3....... field of the table smallcapm from table ppcsmlcap having new value of LTP each time. Following is my requirement : 1. Instead of modifying the above query before running it as per the field like LTP1,LTP2,LTP3.... i want the query to go to the next field ie. from LTP1 to LTP2 to LTP3 etc by successive execution of the query...

Data Execution prevention
I have a huge problem. I am not able to print any PDF that I download. the message I am getting is re Data Execution prevention. So I changed the settings so I "Turn on DEP except for thos programs that I select (and included Adobe Acrobat in the list to check to turn DEP off.). Hasn't made a difference, despite restart after restart no change. Windows is up to date, Adobe is up to date, have firewall cannot think of any other items to check. The error message is always the error re DEP. Any suggestions? On Mar 17, 3:59=A0am, suek <s...@discussions.microsoft.com...

How to Stop Worksheet_Change event from running during code execution
I'm sorry If I've asked this before but I can't find an answer to it. I have the following 2 events in a worksheet module.... Private Sub Worksheet_Change(ByVal Target As Excel.Range) Private Sub Worksheet_SelectionChange(ByVal Target As Range) I run some codes, either in UserForms or general procedures that make changes to this worksheet. Q. Is there a way to by-pass those two events somehow? As an example I have a uf that comes up if a cell is selected in that sheet. So I need those worksheet_Change events to work at that point. But then, the uf does some stuff like inputing ...

SQL Server 2005 sp3 Query Execution Issue
I am running this really complicated olap query on my workstation (xp 64 bit) which takes roughly 8 minutes to complete. During execution the cpu utilization is pushing 100% but oscilates. When I run the same query against a db containing the same data on windows server 2003 on a machine which is much more powerfull with scsi hard drives, it executes forever. The log looks good. However, the cpu utilization is at rest at 100% and memory is growing over time. Any troubleshooting suggestions is greately appreciated. Thanks in advance RG Indexes are speed up the queries. ...

DoEvents and CPU usage
I have the following loop: Do Until <something happens> Do Events Sleep 50 'refers to Private Declare Sub sapiSleep Lib "kernel32" Loop I added Sleep because I don't like 100% CPU usage that DoEvents alone would cause (e.g., because of overheating in my dynamically switched Centrino). Written as above, the CPU usage is almost 0, and all my other Access windows still react to my clicks. But the calculated controls in other windows now take FOREVER to calculate :( Is there a way to do something like "DoEvents 1000", which would let the rest of Acce...

Executing DOS command
Hello, I am developing an MFC SDI application using VC6 running on WinXP. I am using the CreateProcess() function to execute the DOS copy command. cmd "copy file1.txt file2.txt" The program displays a DOS box with a flashing prompt. It's like the "copy file1.txt file2.txt" is ignored. Any ideas? TIA, Jacques "Jacques Cooper" <jcooper@jcsoftware.net> wrote in message news:#CsFen4XDHA.1480@tk2msftngp13.phx.gbl... > Hello, > > I am developing an MFC SDI application using VC6 running on WinXP. > I am using the CreateProcess() function to ...

get smaller executable than 20kByte
Hello all, is there a way to compile smaller shared-library mfc-exe than 20kByte? There must be room for smaller files because the exe is compressed only 3kByte. Is there a compiler setting or a way to prevent this large areas that are filled with acsii0? Thanks & Regards ZZT, You can remove the dependencies of the CRT to save some space. You can also use the /align:4096 linker switch to (sometimes) save some space. There is another option which is similar to /align, I think it is something like /opt:nowin98 which may save some space also. There is also a program called PECompa...

Execute As
Greetings. I have 2 Databases with 2 different sets of users, and thus 2 different sets of permissions. Certain actions on Database A fires a trigger that executes a stored procedure on database B. If the user in Database A doesn't have permission on Database B, then the procedure fails, and the User gets an error. I have been experimenting with the EXECUTE AS function, but it doesn't seem to work as I had expected. Can anyone give me some tips or point me in the direction of some holiday reading material? Thanks in advance. Matthew Vandermolen Solutions Architecht Worktec...

DoEvents and Execution
I'm using AC2003. I have FormA which has two subform controls on it which do not have a SourceObject assigned to them. I do that in the form_open event, see below. What I'm trying to do is to open a simple OneMomentPlease form that has several colored labels used to indicate progress. As I understand it, a DoEvents statement should force all statements prior to it to execute before any following statements to execute. However, it's not working that way. When FormA is opened it runs through all statements. Each sourceobject contains a fairly complex chart and ta...

Program stops executing
I have an instance such that any VB program will not work on a certain PC. It used to, but now the VBNET2005 generated executable will now not execute. I have tried creating a simple project with just a form on it with Hello World in a textbox and even that will not execute in runtime. There is no question of the framework not being installed because it comes standard in the Windows XP SP2 and I have SP3 installed on the PC. I have uninstalled and reinstalled the DotNet framework and this has NOT resolved the issue. Can anyone please shed some light on this matter for me a...

BackgroundWorker.Cancel only works with DoEvents()
I have an application that is using a BackgroundWorker but the worker can get interrupted if the user wants to move on (it pulls a directory list but the user can navigate away if they want). When the user navigates I check _worker.IsBusy and is it's true I call _worker.CancelAsync(). Then I have a wait loop until the worker is no longer busy: while(_worker.IsBusy) { //Here's where my problem is } If I use Thread.Sleep(0) or just leave the loop empty, IsBusy never gets set to false. But is I use DoEvents it gets set and all the cancellation works fine. I'm not...

Executive Assistant
I read my boss's email and send out the action items to staff members. The problem I have is letting the boss know that I have replied to the sender and that the task has be sent out for action. Currently I copy the message over to my boss's task list and annote the actions I have taken. I then mark the message as unread. This requires my boss to "go look" for the email in his task list to see if I have done anything with the task. I have not found a way to easily say, "Hey boss, I replied to Mr. Smith and I have given the tasking to Ms. Davis. They will...

Equivalen DoEvents method
Hi all, I'm writing an MFC Document/View application. In the CMyDocument construct create an object that spend about 20 seconds before been created. My program that waiting 20 seconds before the view is displayed. Is it possible resolve this, and display view immediately without waiting the creation of my object ? My application is single thread. Thanks stefano What is it doing for 20 secs? If you want to free up UI then you should do that work in a worker thread. You can display the view immediately if all that is needed to display it is present. IOW, data that is to be displayed in...

Events in Excel for executing functions
Is there any special event that excel fires when a specific calculation is completed in a CELL. For example in Cell A5 I have =FuncLookAtAllDBRequest("SomeStringID") When this function completes I need to know whether I can call some macro to send me an email using VBA. Are there any events that tell BeforeFunctionCalled(".....") or AfterFunctionCalled(".....") etc.... Is this already there is Excel or are there any VBA code sample that will do it. I have several functions been called within a sheet they do scientific calculation and I need to notify the needful...

Executables
Hello - I have a general question re executables. If users have a shortcut to an executable that resides on an application server, where is the application actually "running" from? Does it "run" on the client computer? Does a copy of it "run" on the client computer? How many people can run a shortcut that points to one executable at the same time? -- Sheldon =?Utf-8?B?U2hlbGRvbg==?= <Sheldon@discussions.microsoft.com> wrote in news:F3F8089C-11E8-4DDF-98D8-3B4133E6E328@microsoft.com: > Hello - > > I have a general question...

How can an assembly work without the SequrityPermission that give it execute permission
Hi! I have the following three declarative permissions. [assembly:RegistryPermission(SecurityAction.RequestMinimum, Read=@"HKEY_LOCAL_MACHINE\Software")] [assembly: UIPermission(SecurityAction.RequestMinimum, Unrestricted=true)] [assembly:RegistryPermission(SecurityAction.RequestOptional, Read=@"HKEY_LOCAL_MACHINE\Software")] Now to my question the assembly only have the following permission 1. RegistryPermission 2. UIPermission The other has been given away so to speak because of how the RequestedOptional work. So according to me this assembly doesn&...

Auto execute the Button every 20 Minutes
I have button on a form which performs a functions (Importing data) I'd like the button to run automatically every 30 minutes. Pls tell me the "Code" and steps to do it . THank you so much, dear expert ! -- Allen Phailat Wongakanit Set the form's TimerInterval to the appropriate value (1200000 for 20 minutes, 1800000 for 30 minutes), then use the form's Timer event to call the appropriate code. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ali" <ali@discussions.microsoft.com> wrote in message news:2...

application execution
Hi, Is there any necessary to install dotnetfx, when we have a setup of a .net windows application...................? janardhan.... On May 15, 8:23=A0am, Janardhan <janardhan....@gmail.com> wrote: > Hi, > > Is there any necessary to install dotnetfx, when we have a setup of > a .net windows application...................? > > janardhan.... It depends on version of framework and Windows. Version 3.0 of the .NET Framework is included with Windows Server 2008 and Windows Vista. Version 3.5 is included with Windows 7. For previous versions of Windows y...

VB6 Execution Issue
Please don't shoot for the VB post but I know there are a lot of VB Pro's here and this is something I simply cannot figure out. (I'm new to VB so I claim newbie exemption from any critisism.) I'm trying to display a simple countdown using a Label Box Sub with the following code: 190: For intCTR = intNUM To 1 Step -1 200: lblBOX.Caption = "" 210: lblBOX.Caption = intCTR 220: For x = 1 To 1000000 'Meant to delay the countdown. 221: Next x 300: Next intCTR The initial intCTR number appears (5 for example) as expected and the display is delayed by line 220....

Alerts disabled in DoEvents loop
When running a macro that includes a loop with DoEvents alert messages are not shown to the user. In my case locked cells of protected Worksheets do not allow data entry but do not alert the user as to why. Even more problematic the content of these protected cells are delete when the delete key is pressed! This does not occur if the macro is not running. Instead an alert dialog is displayed and the action is cancelled. The problem can be reproduced with the following steps: 1. Create a Workbook and set all cells in a Worksheet to locked 2. Enter values into some of the cells 3. Prot...

Executing a macro
Hi there, I can't find the convenient way to run a macro directly from shortcu on my desktop. I'd like to be able to run a certain macro just b clicking on my visio document shortcut, then this would open m document with everything done! I put the right path, but is possible t add the name of the macro to run? (like for Word: path/M macroname) thanx a lot for your help Avalon2 -- avalon2 ----------------------------------------------------------------------- avalon27's Profile: http://www.officehelp.in/member.php?userid=18 View this thread: http://www.officehelp.in/showthread.p...