Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how do I set up a progress bar with messages?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

829 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