Progress bar within a form

TUSSFC

Registered User.
Local time
Today, 18:14
Joined
Apr 12, 2007
Messages
57
Wasn't sure whether to post this here or in the forms cat. As it involves code, I chose here.

I'm trying to simulate a progress bar within a form using a textfield. I've found the following code on t'interweb but cannot get it to work. When I click the command button to start the progress bar nothing happens.

On the form load event I have:

Code:
Private Sub Form_Load()
 
Progress.Width = 0
Progress.BackColor = 16711680
End Sub

On the command buttons click event I have:

Code:
Private Sub b_Go_Click()
 
Dim i As Integer, x As Double
Dim num As Integer, start As Double
 
num = 1000
x = 6237 / num
 
For i = 1 To num
 
start = Timer
Do While Time < start + 0.02
DoEvents
Loop
 
Progress.Width = i * x
 
Next i
 
End Sub

num will, at some point, be the number of records which are querying but for interim is a dummy value for the sake of testing the thing works.

x is the width of the textbox (11cm) converted into twips.

Any ideas where I'm going wrong? No errors when debugging and I don't think I need any references for this to work.

Thanks.
 
Doh ... typo.

Do While Time < start + 0.02

should be

Do While Timer < start + 0.02
 
Hi

I managed to get the progress bar working with the typo amendment above.

However ...

I now need that code to execute at the same time as executing an append query.

The "num = 1000" value reflects the number of records in the query recordset.

There is a simple command button on a form ... when the user clicks it needs to run the append whilst executing the progress bar to indicate the progress.

Sounds simple .. but I can't work out how to construct the onClick VBA to run the two actions simultaneously :-s
 
Access is single threaded and will only execute one thread at a time. Sorry.
 
If a progress bar is needed bad enough you can append via a recordset and put code in the shows progress...
 
This thread has gotten me 90% to the solution to my problem, but I've fallen at the last hurdle.

My form has an On Load event which:
  1. Updates an Action Caption
  2. Calls a Function for that Action
  3. Updates the Progress Bar by 10%
  4. Updates a Status Caption
There are 10 steps in total, and each function hands control back to the form before the next is called, so the form should update but it doesn't, until the end.

Clue?
 
Put in

DoEvents

prior to starting the function call
 
Put in some DoEvents to give Access time to update the other form.
 

Users who are viewing this thread

Back
Top Bottom