Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

progressbar with queries problems.

Status
Not open for further replies.

mattyp75

Programmer
Aug 28, 2002
16
GB
Is it possible to add a progressbar to a form on which a query is running, like when you run a query in Access? I have tried various things, but have not found a way to do this. If anyone knows it would be most helpful. Also when I run the code below from a click even on a command button the form doesn't refresh. How do I get it so that the form refreshes while the query is running? Any help would be thankfully received,
Matt

Here is just a snippet of the code. The variables are passed to this by combo boxes.
 
When we see your code we can comment better. In the meantime check that you've got a DoEvents in your loop (assuming you are looping)
You can force a form repaint with:
Me.Refresh
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
While the query is running, VB is not getting any CPU cycles, so there's no way to have a progress bar that updates as rows are brought back.

You could hack something up that partitions your data via the WHERE clause:
WHERE InvoiceID BETWEEN (1,100)
' Update progress bar
' DoEvents
WHERE InvoiceID BETWEEN (101,200)
' Update progress bar
' DoEvents
WHERE InvoiceID BETWEEN (101,300)
' Update progress bar
' DoEvents

But that's real ugly, and introduces data set dependencies into your code. You'd also have to figure out how many rows in total are going to be returned, which means you have to run the query twice - once as a SELECT Count(*), and once for real. Bad bad bad.

A better way would be to make an effort to write a faster query, either via a stored procedure, or by using SQL Query's execution plan display. Or if that's not possible, your could resort to an .AVI file, like Windows Explorer does when it's copying files to distract the user.

Chip H.
 
Sorry about the above post, I did include the code, but I was posting from where i work and it is behind a firewall that strips VB code i think. I will post the code tomorrow as I don't have it with me right now. Thanks for your suggestions. I am using VB6 to connect to an Access 97 database. I am connecting via DAO and running an SQL statement. I will update the problem tomorrow. Thanks for all your responses,
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top