473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Progress Meter does not refresh during series of OpenQueries

I have a macro that needs to have a progress meter displayed since it
is long running. I moved the Macro's instructions to a table and pulled
those records into a recordset that is looped through.
PROBLEM -- The form, with a progress meter and labels to inform the
user as to which step of a series of instructions is being done and the
overall progress, seems to lock from repainting after the first
docmd.openquery because the form is never updated until ALL the
openqueries are done.

Any advice out there?

DoCmd.OpenForm "PROGRESS"
Dim frm As Form
Set frm = Forms("PROGRESS")
Dim ctrl As Control
Set ctrl = frm.Controls("lblMessage")
ctrl.Caption = "PLEASE WAIT...." & vbCrLf & "Starting Audit"

Dim lblHdr As Control
Set lblHdr = frm.Controls("lblHeading")

Dim lblTime As Control
Set lblTime = frm.Controls("lblTime")

DoEvents
Set conn = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.Open "select * from AuditOrders", conn, adOpenDynamic,
adLockReadOnly

Dim count As Integer
Dim currCount As Integer
count = 0
currCount = 1

If Not rs.EOF Then
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
End If

If count <= 0 Then Exit Function
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.SetWarnings False

updatemtr 0, count
frm.Repaint

rs.MoveFirst

Do Until rs.EOF
DoEvents
recordval = rs!Value
recordType = rs!TYPE
recordHeading = rs!heading
active = rs!active

lblHdr.Caption = recordHeading
ctrl.Caption = "Executing " & recordval
updatemtr currCount, count
DBEngine.Idle dbRefreshCache
frm.Repaint

Select Case UCase(recordType)
Case "QUERY"
DoCmd.OpenQuery recordval
DoCmd.Close acQuery, recordval
frm.Repaint
Case "REPORT"
'DoCmd.OpenReport recordVal, acViewPreview, , ,
acWindowNormal
Case "CODE"
'Call Val(recordVal)
End Select

Sleep (100)
currCount = currCount + 1
rs.MoveNext
Loop

Exit_Function:
DoCmd.Hourglass False
DoCmd.Echo True
DoCmd.SetWarnings True
MsgBox "AUDIT DONE.", vbOKOnly, "AUDIT COMPLETE"
DoCmd.Close acForm, "PROGRESS"
Exit Function

errorhandler:
If ERR.Description <> "" Then MsgBox "AccuReg Error" & vbCrLf &
ERR.Description, vbOKOnly, "ERROR"
Resume Exit_Function

Dec 24 '05 #1
4 2903
bfulford wrote in message
<11*********************@o13g2000cwo.googlegroups. com> :
I have a macro that needs to have a progress meter displayed since it
is long running. I moved the Macro's instructions to a table and pulled
those records into a recordset that is looped through.
PROBLEM -- The form, with a progress meter and labels to inform the
user as to which step of a series of instructions is being done and the
overall progress, seems to lock from repainting after the first
docmd.openquery because the form is never updated until ALL the
openqueries are done.

Any advice out there?

DoCmd.OpenForm "PROGRESS"
Dim frm As Form
Set frm = Forms("PROGRESS")
Dim ctrl As Control
Set ctrl = frm.Controls("lblMessage")
ctrl.Caption = "PLEASE WAIT...." & vbCrLf & "Starting Audit"

Dim lblHdr As Control
Set lblHdr = frm.Controls("lblHeading")

Dim lblTime As Control
Set lblTime = frm.Controls("lblTime")

DoEvents
Set conn = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.Open "select * from AuditOrders", conn, adOpenDynamic,
adLockReadOnly

Dim count As Integer
Dim currCount As Integer
count = 0
currCount = 1

If Not rs.EOF Then
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
End If

If count <= 0 Then Exit Function
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.SetWarnings False

updatemtr 0, count
frm.Repaint

rs.MoveFirst

Do Until rs.EOF
DoEvents
recordval = rs!Value
recordType = rs!TYPE
recordHeading = rs!heading
active = rs!active

lblHdr.Caption = recordHeading
ctrl.Caption = "Executing " & recordval
updatemtr currCount, count
DBEngine.Idle dbRefreshCache
frm.Repaint

Select Case UCase(recordType)
Case "QUERY"
DoCmd.OpenQuery recordval
DoCmd.Close acQuery, recordval
frm.Repaint
Case "REPORT"
'DoCmd.OpenReport recordVal, acViewPreview, , ,
acWindowNormal
Case "CODE"
'Call Val(recordVal)
End Select

Sleep (100)
currCount = currCount + 1
rs.MoveNext
Loop

Exit_Function:
DoCmd.Hourglass False
DoCmd.Echo True
DoCmd.SetWarnings True
MsgBox "AUDIT DONE.", vbOKOnly, "AUDIT COMPLETE"
DoCmd.Close acForm, "PROGRESS"
Exit Function

errorhandler:
If ERR.Description <> "" Then MsgBox "AccuReg Error" & vbCrLf &
ERR.Description, vbOKOnly, "ERROR"
Resume Exit_Function


Try the following

In the loop, replace frm.Repaint with DoEvents. It should only be
necessary after altering the captions.

--
Roy-Vidar
Dec 24 '05 #2
I have a doevents right after the do until... does it really matter
where in the loop I place it?

Dec 24 '05 #3

"bfulford" <br***********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I have a macro that needs to have a progress meter displayed since it
is long running. I moved the Macro's instructions to a table and pulled
those records into a recordset that is looped through.
PROBLEM -- The form, with a progress meter and labels to inform the
user as to which step of a series of instructions is being done and the
overall progress, seems to lock from repainting after the first
docmd.openquery because the form is never updated until ALL the
openqueries are done.

Any advice out there?

DoCmd.OpenForm "PROGRESS"
Dim frm As Form
Set frm = Forms("PROGRESS")
Dim ctrl As Control
Set ctrl = frm.Controls("lblMessage")
ctrl.Caption = "PLEASE WAIT...." & vbCrLf & "Starting Audit"

Dim lblHdr As Control
Set lblHdr = frm.Controls("lblHeading")

Dim lblTime As Control
Set lblTime = frm.Controls("lblTime")

DoEvents
Set conn = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.Open "select * from AuditOrders", conn, adOpenDynamic,
adLockReadOnly

Dim count As Integer
Dim currCount As Integer
count = 0
currCount = 1

If Not rs.EOF Then
Do Until rs.EOF
count = count + 1
rs.MoveNext
Loop
End If

If count <= 0 Then Exit Function
DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.SetWarnings False

updatemtr 0, count
frm.Repaint

rs.MoveFirst

Do Until rs.EOF
DoEvents
recordval = rs!Value
recordType = rs!TYPE
recordHeading = rs!heading
active = rs!active

lblHdr.Caption = recordHeading
ctrl.Caption = "Executing " & recordval
updatemtr currCount, count
DBEngine.Idle dbRefreshCache
frm.Repaint

Select Case UCase(recordType)
Case "QUERY"
DoCmd.OpenQuery recordval
DoCmd.Close acQuery, recordval
frm.Repaint
Case "REPORT"
'DoCmd.OpenReport recordVal, acViewPreview, , ,
acWindowNormal
Case "CODE"
'Call Val(recordVal)
End Select

Sleep (100)
currCount = currCount + 1
rs.MoveNext
Loop

Exit_Function:
DoCmd.Hourglass False
DoCmd.Echo True
DoCmd.SetWarnings True
MsgBox "AUDIT DONE.", vbOKOnly, "AUDIT COMPLETE"
DoCmd.Close acForm, "PROGRESS"
Exit Function

errorhandler:
If ERR.Description <> "" Then MsgBox "AccuReg Error" & vbCrLf &
ERR.Description, vbOKOnly, "ERROR"
Resume Exit_Function


What is updatemtr?

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Dec 24 '05 #4
"bfulford" <br***********@gmail.com> wrote in
news:11**********************@g47g2000cwa.googlegr oups.com:
I have a doevents right after the do until... does it really matter
where in the loop I place it?


I really don't know, I've just always done the assigning to the form
controls, then used DoEvents immediately after, and it has worked. But
since no one else has responded, a couple of more thoughts, though I
haven't the foggiest whether they address the immediate issue ...

I would "second" Randy Harris question though, what is updatemtr, and
does it contain anything that could prevent the form from updating?

Also, there are some other things in your code that could provide
anomalities - your usage of reserved words, for instance Count, Value and
Type, which are properties of lots of objects, see (watch for linebreaks
in the link)
http://support.microsoft.com/default...b;en-us;286335

But I don't know whether this has anything to do with the form not
updating.

You have also declared a variable named lblTime as Control, and then
assigned to it the form control "lblTime" - at least when working in the
form class module, this might provide anomalities.

Also, why do you make it sleep? If this is needed, I'd try to stuff a
DoEvents between updating the form controls and the Sleep.

If no one else responds, I'd suggest to simplify the routine (comment out
larger parts of it) and see at which time/alteration you are able to get
the updating of the form to work, then see what is the cause, and see if
you can work around it.

One suggestion that will probably save some time for you at a later time
(which I'm "rude" enough to suggest;-), is to start using a naming
convention that will prevent you from using reserved words when designing
your dbs.

--
Roy-Vidar
Dec 26 '05 #5

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

Similar topics

4
by: Ron | last post by:
I spent the last couple of days setting up a progress indicator for a private site that only does a couple uploads a day. After figuring out there was no way to set the 'upload_tmp_dir' or...
2
by: Julia Briggs | last post by:
Hello, I've read quite a bit of discussion on different approaches of how to create a download progress meter that can be implemented into a Web site. I understand that by the very nature of...
13
by: Martin Mrazek | last post by:
Hi, I check data validity in html form by JS. Something like for (i=0; i<document.form.elements.length; i++) { chechkValidity(i); } Unfortunately, the form has about two thousands elements...
3
by: Brian Birtle | last post by:
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible to build a file upload progress meter using ASP.NET" **** First person to prove me wrong gets "All Time .NET Programming GOD"...
1
by: Doug | last post by:
In I.E. 6 (and probably other versions as well), there is a sort of progress meter in the panel at the bottom of the window. This meter increments a few pixels at a time when the browser is trying...
8
by: Brian Henry | last post by:
I created a smooth progress bar with this code.. but if you update the values in a row quickly of it and watch it on screen it flickers... how would i change this to reduce the flickering?...
23
ADezii
by: ADezii | last post by:
Many Access Users fail to realize that it has a built-in Progress Meter that can display the relative completion percentage of various processes. It is fairly limited, but nonetheless, does provide...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.