Solved

how do I set up a progress bar with messages?

Posted on 2004-08-13
4
139 Views
Last Modified: 2010-05-02
Dear Experts,

I have an access application that uses tables in access to create custom documents in Word.  All sorts of stuff is happening... certain sections are eliminated based on checkboxes that the user enters into forms, certain text is replaced... certain things are formatted... all based on how the user specified things on forms.

It turns out that MS Office is working pretty hard doing all these things (there are quite a few replaces, etc).  Rather than have the user stare at the computer for a minute while its crunching, I would like to set up a progress bar that both shows progress and also a message about what the app is doing at the moment.  

I would imagine that I could set it up as a function sub where I send it a little message from whatever routine Im running that contains the message text as a string.  The bar should then increment a certain amount while displaying the message and then return to the current sub.  Can someone help me out with the syntax of this routine by providing a code example of the sub and explaining how to call it?  
0
Comment
Question by:meuedyn
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 350 total points
ID: 11795037
Here is an example:

First form (need one command button)

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
    Dim i As Integer
   
    Form2.Show
    For i = 1 To 100
        Call Form2.DisplayProgress("Processing Item " & i, i)
        Sleep 100
    Next
    Unload Form2
End Sub

Second form (need progress bar and label):

Public Function DisplayProgress(strMessage As String, Percent As Integer)
    lblInfo.Caption = strMessage
    proBar.Value = Percent
    DoEvents
End Function
0
 

Author Comment

by:meuedyn
ID: 11805999
Thanks!  This worked like a charm.. You get full points.. but Ill wait a day before I close the thread, because I was wondering if youcould tell me the significance of the "DoEvents" command... it ran perfectly with and without it.

Thanks!

-meuemeue Dyn
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11913910
DoEvents yields execution so that the operating system can process other events. I always use DoEvents when I have to display some progress (a few labels and progress bar). If you don't use DoEvents there are some situations (depending on that what application is working), when label captions are not updated (they are from code, but user can not see any changes on the form, and form gets ugly look). I am using DoEvents to prevent this behaviour.

HTH

;)
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11913936
From MSDN:
DoEvents switches control to the operating-environment kernel. Control returns to your application as soon as all other applications in the environment have had a chance to respond to pending events. This doesn't cause the current application to give up the focus, but it does enable background events to be processed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question