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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desperate question about progress bar

Status
Not open for further replies.
Nov 6, 2002
89
CH
Hi

I would like to implement a progress bar when opening a report (report is loaded from a command button on a form). The opening of the report may take a while (up to 4 minutes) due to complexity of the underlying crosstab query.

I found some samples online on the web but however, I did not yet figures out what code I need and how and where to add it.

Can someone clearly indicate me in a simple way how I can create such a progress bar? (which code, where to put the code, etc.). That would be just great, folks.

Thank you so much. You will make my day.

Stefan
 
I use this in a little different situation. I am processing data in a loop like this.

For i = 1 to 1000
call UpdateProgress(i,1000,"Testing")
call ProcessMyDataHere
Next i

I have a form called Progress it has a label names PCT and under that a Label named BAR. Both have a max width of 5 in.


Option Compare Database
Option Explicit

Sub UpdateProgress(i As Long, RowCount As Long, Mode As String)
On Error GoTo Error

Dim UnitSize As Double
Dim X

' 1440 twips = 1 inch. my bar is 5 inch max
UnitSize = ((1440 * 5) / RowCount)

Forms!Progress.Controls!BAR.Width = (UnitSize * i)
Forms!Progress.Controls!Pct.Caption = Format((i / RowCount), "##0 %")
Forms!Progress.Caption = Format(i, "#,##0") + " of " + Format(RowCount, "#,##0") + " Records " + Mode
Forms!Progress.Repaint

ExitSub:
Exit Sub

Error:
MsgBox Err.Description
Resume ExitSub

End Sub CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining
 
Hi Charles

Thank you so much for your answer. I will try to implement this into my database.

One question before starting the implementation. Where do I have to add the below code:

For i = 1 to 1000
call UpdateProgress(i,1000,"Testing")
call ProcessMyDataHere
Next i

Does it have to be included in the onclick event of the command button? Please note that the command button has already a OpenReport procedure.

Thank you.

Stefan


 
Thats a big question in a small message.

It really depends on how your application works. In my previous post it was just to show using a progress bar in a loop.

What you need to do is figure out the basic parts of the time you are waiting on.

call UpdateProgress(i,1000,"Testing")

For example in my code i is the smallest unit of measure. 1000 is the total of i. "Testing" is just text displayed in the title.

So if you are processing a number of things you would put the code in the process loop. If you are just telling the system (access or windows etc.) to do something for you, you may not know how long it will take before it gets back to you. In this case I don't know where to put the code. Is there something you can check to see what it is doing?

This may not be very helpfull in a nuts and bolts way but this issue is an example of what makes the difference between $20/hr programming and $250/hr consulting. Another way of looking at this is if I could tell you where to put the code I would.

Sorry I could not help more. CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining
 
I don't think it's that simple...
Remember, Access is a single-threaded application. One and only one action can take place at a given moment. Updating a progress bar implies some step-by-step code, where you can insert the updating code between subsequent steps. DoCmd.OpenReport is just one step that you can't break into pieces, can't pause, therefore you can't update a custom progress bar while the report is being processed. The built-in progress bar takes advantage of Jet internal processes. And even so, it's not accurate at all, that's a fact.

But of course, I may be wrong (and I'd be happy for that)...

HTH [pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top