Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how do I set up a progress bar with messages?

Posted on 2004-08-13
4
Medium Priority
?
143 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 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