Progress Bar

ColinEssex

Old registered user
Local time
Today, 23:13
Joined
Feb 22, 2002
Messages
9,451
Hi All

I have a form with a command button that runs loads of queries that append data from several Db's to the currentDb.

What I would like to do is have a progress bar doing the biz whilst the append queries are running. I've already got the hourglass but a progress bar would look neat.

I've searched the forum and read Boblarsons reply to a query a couple of weeks ago which was regarding a splash form. I'm not too sure how to make it work with queries running though.

Any clues?

Col
:cool:
 
Colin,
You need only look in Access help. Search for "progress meters" or read up on the SysCmd Function.
 
I have a progress bar but sorry Im not willing to open source this sucker...I know WHY!!!!. Well the reason being is it took a friend of mine quite some time to come up with the idea. I have since modified it to fit my needs and promised not to open source it. The basic idea is to create an unbound form. The form should have a square used to hold the actual progress meter. The meter should start as one SMALL red square...you loop through records and this red square grows based on each record. For instance the width of this square maybe 1 that mean for each record in the recordset the width of the square should grow 1/10 for each record so that 1/10+1/10+1/10...1/10= 10/10=1. This works for any number 'n' of recordsets since you're adding 1/sizeof(recordset) if in the case that the recordset had 100 records the size would grow 1/100 for each record. You can then add a label to hold the percent and increment the percent based on each record. Sorry that I cannot post it.
Jon
 
There are so many free utilities/code snippets out there...
Either on these very fora (you should search better) or on the web (use whichever web-bot). Ex:
Simple Progress bar
 
Whilst I appreciate that I could have spent more time searching though the forum and spending more time searching the internet, I do have a deadline of this Friday for this database, time is of the essence and felt that it may be possible for someone to give me a reply more quickly. If not then fair enough.

I'm terribly sorry for posting what I considered a sensible question (compared to some of the rubbish here) I genuinely do not know how to make a progress bar work with queries, I can do it with a count but not with queries.

I was under the mistaken belief that we were all of one Access family, how stupid.

In future I shall probably not bother posting questions - all I seem to get is sarcastic comments and sly digs. I don't really know why.


Col:(
 
Last edited:
Here's a quick way, just change the length of Max value to suit
Private Sub Button14_Click()
Dim i As Double
Dim ReturnValue As Variant
Dim maxvalue As Double
Dim stepp As Double
Dim X As Variant
Dim Total As Double

maxvalue = 700000
stepp = 100 / maxvalue

ReturnValue = SysCmd(SYSCMD_INITMETER, "Building query", 100)

Response = MsgBox("This may take some time." & Chr(10) & Chr(13) & "Push OK to continue, and Cancel to quit", 1)
If Response = 1 Then
DoCmd.Hourglass True
For i = 1 To maxvalue
Total = Total + stepp
X = Int(Total)
ReturnValue = SysCmd(SYSCMD_UPDATEMETER, X)
Next i
DoCmd.Hourglass False
End If

ReturnValue = SysCmd(SYSCMD_SETSTATUS, "Updating query")
ReturnValue = SysCmd(SYSCMD_REMOVEMETER)

End Sub
 
Thank you Rich, I shall give that a try later today, it looks good.

Col
 
Rich

That works well on a quick test, I can think of a couple of uses:cool:

Col

Take no notice and ask away this post has been useful to me even if some people do feel its a waste if time
 
Colin Essex,

I am very surprised by your reaction.

1. There was no indication in your post about your deadline. So,
there was no mean for people willing to help to know that they had to be particularly quick and comprehensive.

2. In my particular case, not knowing that this was an emergency for you, I was about not to answer at all if it were not that I considered misssion's answer 'dry' to say the least.

3. First sentence in my post was as the same time directed to mission who seemed to make a secret of having re-invented the wheel, and to let you know that there were many ready to use examples available.

4. Second sentence was less about criticism than about telling you that if the sample code I was about to provide was not what you were looking for, you could relatively easily find other ones, and how you could.

5. Last line was to provide you with a code sample (hyperlink to a free, easy and quick to use sample DB)

6. I feel odd that I may have to justify why and in which way I tried to help you. But since you seem to consider that this is the case, let me state that I took about 10 minutes of my time on a *very* busy day to actually do a search on Internet and provide you that hyperlink, thus doing the most that I could on that circumstance given my own obrigations: I have been working on concluding, before the end of the week, the preparation of an emergency humanitarian assistance program for a country scourged by war. However, I took that time without hesitation because I needed a break and thought I could help.

That were my motivations and state of mind at the time.
But now, I do not just feel surprised but also irritated by your attitude. So, I will say it straight:

1. You cannot expect people to read you mind. If you have particular expectations, you should do the minimum effort of being accordingly informative about your needs in you post.

2. You should grant people the benefice of doubt that they may have much more important things to do than post void comments in jest or 'sarcastic comments' or 'sly digs', and conversely that when they post this may represent a real effort from their part to help you.

3. You should understand that the contributions you receive represent what people can offer you at a given time based their own constraints and obrigations. Therefore they may not be always equally comprehensive according to the specific moment, person, subject, and his/her understanding of your request.

4. There are a number of so widely treated subjects that indicating you resources like the search feature, internet, or the Access help are pointers to quick means to find help, not signs of contempt.

5. Whatever your urgent need and the way you may make it clear through your request, you cannot take for granted that you will get a fully detailed, ready to implement answer. It may happen. I believe that people on the fora know that I do so when I can.
But as a matter of fact, help can not always match your expectations.
If so, then, as you say: 'fair enough'.
Since as far as I know there is no one on this site whose obrigation or paid occupation is to provide help, when not grateful for the contributions received, you should at least not be despiteful.

Regards.
 
Last edited:
Alex,

What was so "dry" about my reply? I worked hard at creating this progress bar and the one's I have seen do not fit my needs nor are they near as close as nice as the form I had worked on. Maybe you're the type who likes to work out something and spew it out giving it for free so that others don't even use a little time to work out a problem. People should NOT expect ANSWERS ALL of the time. They should be willing to take suggestions and work out problems on there own. Having said that and reading my post and your post I don't see how you think I'm the wrong one here. Shape up or ship out.
Jon
 
Mission,

I did not say that you were 'the wrong one'. I don't even have a clue about what this means in this context. We also share the same ideas about the benefit of letting people work out part of their problems by themselves as we've all been doing.

I said 'dry at the least' because at our level of 'expertise' talking about not 'open sourcing' code is a bit of an exageration. Let's be humble and realistic and recognise that for about all the issues raised on this site there are sample code, db and utilities available either on this forum or others, or dedicated sites on the net. And my opinion is that all these examples leave still more than enough room for personal work, to be understood and adapted to particular situations.

I am plainly conscious that this my a personal view and others may not suscribe to it. I just frantically said it because this is actually what made me step into this thread.
And so did I thinking I would give a pointer about where to find examples. As a matter of fact Colin thinks nonetheless that I am a 'wrong one' because this was not enough for him.

I think that illustrates another point we apparently also agree upon: that you cannot demand to get 'the' answer you want and cannot present yourself as victim when you don't. If someone happens to provide what you expected, fine. Shape up.
If not, pursue the dialogue. People step in to actually try to help.
If you're not willing to, ship out.
 
Hmph,

Last time I checked most of my messages have been helpful. In any event Collin doesn't seem to need the progress bar after all this arguing. I would not mind giving it out but since Im not the complete author I cannot. I have modified this progress bar but that certainly does not mean that its officially mine nor am I taking credit for it. I explained the concept and that should get you going. Its all about LEARNING to do things not just "Hey I need this and I need it in X amount of time because my boss will fire me." Its about here's a method, try this, here's something similiar, or modify this. This not only gives a little clue to the developer but also gets them to do a little bit of the work on their own. We all have received help but we shouldn't expect to come in here just to take things from others who have worked on them...think of it like school. You can share your ideas but you cannot copy them.....otherwise there's a consequence. At least there was in my schooling. Sorry if this caused any problems....back to work.
Jon
 
Depending on the installation of Access you have, some extra features aren't there. But there is still hope. The approach I use is rather simple-minded but effective.

Build two rectangles. Make one the maximum length of the progress bar. The other should be shorter. Make the long one have a white (or other suitable) background color (fill color). Make the shorter one your favorite bright color. (I use red, but that's just a person preference.)

Make the left upper and lower corners of the two boxes coincide, with the shorter box on top of the longer one, visually speaking. (Move To Top - it is one of the controls in Form Design view)

OK, now some VBA code is needed. When no progress is to be shown, make both rectangles invisible. When you are starting the process, make the long box visible.

In the code behind whatever you do to start the process, try to estimate or count the number of elements you need. Call this number loMax. The index of where you are in the computation will be loCur. Now, if the long rectangle is recLong and the short box is recShort, ...

When starting the process, make recShort.Visible true. Make recShort.Width=1

Now inside the loop, every time you complete one step, make a computation, which unfortunately MUST be in VBA:

recShort.Width = ( loCur * recLong.Width ) / loMax
me.repaint

This will be your progress bar. The units of width are Twips, which is pretty small if you have a large desktop. You can easily get a few hundred twips in recLong and still not make it too big to handle.

When your computation finishes, all you have to do is make both recShort and recLong invisible (.Visible=false)

This might not do you any good right away, but who knows? Later you might wish to try this. File it away for future use.
 
Colin,
For my part, I apologize. I may well have appeared hasty in assuming that you did not research the matter. I did not assume that but, in retrospect, I feel that it could very easily have been taken that way. I should have chosen my words more carefully.

Respectfully,
Shep
 
my only thing is I totally agree with the guy who said that answers shouldnt be readily given, however, what about the people that don't know code, not only dont know code but dont know the difference between a DIM and VAR simple things like that too some can figure it out but some of us dont have the background, or were shoved into a project because we had used a program before... so yes some of us do need a little more help then others, just respect that, thats my only beef but i do agree to a point, there is nothing wrong with helping as long as its not giving the answer straight up but hey, sometimes you need to
just keep helping us little people till we finally grasp the idea of whats going on
 

Users who are viewing this thread

Back
Top Bottom