[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

Threading and progressBar

Hi,

I am looking to create a separate thread that maintains a status screen
whilst running long queries from macros. Currently i update a status bar
inbetween calls to long chain of macros.
Problem being that if the status form gets hidden temporarily then it will
not repaint unitil the next macro is called thus the user has no idea about
where the applicaiton is up to!

I have somewhere in the region of 100 queries run from approx 40 macros.
Each macro is called in turn from code.
I have a statusForm with a progressbar on it.

Ideally i would like to have text that updates every second displaying estimate
time to completion (time taken when last run - time elapsed) but how can
i force it to keep updating the screen in parallel with running my queries?
threading?
 
0
sdom100
Asked:
sdom100
  • 4
  • 3
  • 2
1 Solution
 
BillystyxCommented:
have you tried the form timer event?

Billystyx
0
 
Steve BinkCommented:
First, you will not be able to estimate the length of time for a query.  Access returns no information on this other than still/finished executing (True/False).

Move your macros to code.  You'll be better for it.  VBA code will execute faster, allow more options for optimization of the routines, and allow you to inject your own status monitoring code whereever you feel it is necessary.
0
 
sdom100Author Commented:
Billystyx

On the back of my very easy question, may i quickly just ask another quick n easy one
for the 500 points ;)
When i open my form it's appearing at the size of the whole design window rather than the
size the form was within the design window
Any thoughts?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
BillystyxCommented:
do you have a docmd.maximize on the on current or on load event of the form?

Billystyx
0
 
sdom100Author Commented:
No - no code at all - well, none relating to the form anyway.

I have generated a problem with your solution. :(
the timer worked well when the processor use was low
BUT
when i am running big queries, the query doesnt appear to be yielding the processor
so the form isnt updating at all!!!!!
0
 
BillystyxCommented:
With the maximize, when you are in design view, what happens if you push the button between minimize and maximize on the form?
Does it shrink the window down?
If so then that is all the problem is - once you shrink it down to 'normal' size and open in form view it will show its original size.

Billystyx
0
 
BillystyxCommented:
and on the other point, I would say routinet's suggestion is the way to go -
In code (on a button click) you could do something like

mySQL1="insert into table1 values(etc"
mySQL2="insert into table1 values(etc"
mySQL3="insert into table1 values(etc"
mySQL4="insert into table1 values(etc"
mySQL5="insert into table1 values(etc"
Currentdb.execute mySQL1
'update progress bar
Currentdb.execute mySQL2
'update progressbar
Currentdb.execute mySQL3
'update progressbar
Currentdb.execute mySQL4
'update progressbar
Currentdb.execute mySQL5
'update progressbar

Billystyx
0
 
Steve BinkCommented:
A point to remember is that Access runs queries one after the other, and dedicates all available resources to making it happen.  Nothing will be able to execute with a query in progress, including form updates, timer events, etc.  The most you can expect is to update your status bar to "Running Query 1 of 5", etc., AFTER each query has been completed.  For loops in your code, you can insert a DoEvents call to allow Access time to update the form appropriately, but queries do not allow that luxury.
0
 
sdom100Author Commented:
Thanks
It's a real shame that microsoft will not trust one with the ability to change the priority of the form thread!
I will go with the splitting it down approach and bin my realtime clock :(

Sorry to routinet for the lack of points for your answer!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now