DoEvents and Execution

P

PeterM

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
 
J

Jerry Whittle

DoEvents allows Windows to do things. It passes control to the OS and not the
database.
 
J

Jerry Whittle

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.
 
J

John Spencer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top