?
Solved

how do I set up a progress bar with messages?

Posted on 2004-08-13
4
Medium Priority
?
142 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
[X]
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
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 1050 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

770 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