Simple Progress bar - cant get it to work

ianward

Registered User.
Local time
Today, 00:15
Joined
May 1, 2007
Messages
52
Afternoon all,

I am trying to create a very simple progress bar that just continually scrolls and resets to show something is working, I have a query that runs off sqlserver that takes around 5 mins to run and make the table, what i wanted to do was just to show that something was happening

Idea was to have a small popup form open with a continual progress bar that uses a simple loop as below on the timer event set to 500 - so it should update every 0.5 sec.

Code:
Private Sub Form_Timer()

Dim ProgBar As String
Dim Counter As Integer

Counter = Counter + 1
ProgBar = ProgBar & "n"

If Counter = 10 Then
Counter = 0 And ProgBar = ""
End If

Me.txt_progress = ProgBar


End Sub

the textbox uses the wingding font so should have presented a scrolling progress bar that when it reaches the end starts again.

I would then close programatically after the query has finished,

but - the form opens, waits 0.5 sec puts in the first "n" and then stops... can anyone see what i am doing wrong??

Many Thanks - Ian
 
Access has a problem of doing more than one thing at a time. I do not think it is possible to get a form to refresh to show your progress bar while a query is running. The builtin system progress bar that is displayed at the bottom of the application window is quite accurate.
 
Afternoon all,

I am trying to create a very simple progress bar that just continually scrolls and resets to show something is working, I have a query that runs off sqlserver that takes around 5 mins to run and make the table, what i wanted to do was just to show that something was happening

Idea was to have a small popup form open with a continual progress bar that uses a simple loop as below on the timer event set to 500 - so it should update every 0.5 sec.

Code:
Private Sub Form_Timer()
 
Dim ProgBar As String
Dim Counter As Integer
 
Counter = Counter + 1
ProgBar = ProgBar & "n"
 
If Counter = 10 Then
Counter = 0 And ProgBar = ""
End If
 
Me.txt_progress = ProgBar
 
 
End Sub

the textbox uses the wingding font so should have presented a scrolling progress bar that when it reaches the end starts again.

I would then close programatically after the query has finished,

but - the form opens, waits 0.5 sec puts in the first "n" and then stops... can anyone see what i am doing wrong??

Many Thanks - Ian

Some slight tweaks to your code would make it work.

Code:
Private Sub Form_Timer()
Static ProgBar As String 'you need to declare these as static, otherwise each time you leave the loop they are wiped out
Static Counter As Integer
Counter = Counter + 1
ProgBar = ProgBar & "n"
If Counter = 10 Then
Counter = 0'need to put these on a seperate line, And is a logical operator so putting counter = 0 And Progbar="" is telling VBA to logcially AND those two things together 
ProgBar = ""
End If
Me.txt_Progress = ProgBar
DoEvents 'This will allow the screen to update if other processing is occuring
End Sub
 
DJKarl - fantastic - works perfectly now just as i had envisaged

Many Thanks
 

Users who are viewing this thread

Back
Top Bottom