Solved

how do I set up a progress bar with messages?

Posted on 2004-08-13
4
136 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now