Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Progress-Status Meter (A2000)

    I have a button on a form which performs a certain amount of code processing.
    The form contains quite a lot of graphics so can be a little slow when being re-drawn.
    What I would like is (with attached,) a Progress-status bar to show, making the user feel there is something happening.
    I came across the attached example and wondered if this can be manipulated to serve the purpose.
    I would presume to open the progress bar on click of the button and then for it to close once the screen has been redrawn.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Progress-Status Meter (A2000)

    Dave,

    There are several ways you can use a progress meter like the one in the sample database:
    1. <LI>If you have some way to gauge your progress, you can give the user exact feedback. In the sample database, a <font face="Georgia">For i = 1 To counter ... Next i</font face=georgia> loop is executed; the loop index i tells you exactly how far you have progressed.

      <LI>If you don't have something like a loop index, but the action you perform can be broken up into distinct steps, you can update the progress meter after each step. Something like

      SetPMeter 0
      instruction 1
      SetPMeter 25
      instruction 2
      SetPMeter 50
      instruction 3
      SetPMeter 75
      instruction 4
      SetPMeter 100

      <LI>If you can't break up the action into steps, you don't have a way to give exact information. You might make a guess how long your action usually takes, and use an OnTimer routine to update the progress meter every half second or so. Since this has no direct relation to the action you are performing, the progress meter may reach 100% before or after the action has finished; it only serves as a rough indication here.
    Note: Access also provides a primitive progress meter in the status bar; you control it with the SysCmd instruction.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    Ok, here's what I've done so far.
    On the form, I've added two unbound texts.

    StartTime
    EndTime

    On the buttons code, first line:
    Me.EndTime=""
    Me.StartTime = Now

    On the buttons code, Last line:
    Me.EndTime = Now

    This gives a timed result on how long the buttons code has taken to execute.

    If I now put the Progress bar on the form, what code do I need to implement it.

    (p.s) Hope you had a good Christmas.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Progress-Status Meter (A2000)

    Dave,

    The Now function is rather crude. To get a better idea of execution time, use the Timer function; this returns a single precision number representing the number of seconds since midnight. To time code, use this:

    Dim t As Single
    t = Timer
    ' your code here
    t = Timer - t
    MsgBox t

    When you have an idea how long your code takes, you can use this as follows:
    <UL><LI>Set the TimerInterval property of the form to 0.
    <LI>In the declarations section of the form module, declare a module-level variable and constant:

    Private Const csngDuration As Single = 5.68 ' Replace this with the estimated execution time
    Private mintIndex As Integer

    <LI>Create an OnTimer event handler for the form:

    Private Sub Form_Timer()
    mintIndex = mintIndex + 1
    SetPMeter mintIndex * Me.TimerInterval / (csngDuration * 1000)
    End Sub

    <LI>In the OnClick handler of your command button, set Me.TimerInterval to the desired interval (in milliseconds) just before the start of the code that you want to execute (but after showing message boxes etc.) and set mintIndex to 0. During your code, you must call DoEvents, otherwise the OnTimer routine may not get called. Reset TimerInterval to 0 after the code.

    mintIndex = 0
    Me.TimerInterval = 250 ' this is milliseconds
    ...
    ' your code
    DoEvents
    ' more code
    DoEvents
    ...
    Me.TimerInterval = 0[/list]

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    Hans
    I'm doing something wrong here.
    Would you mind checking the attached.
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Progress-Status Meter (A2000)

    Dave,

    You forgot to copy the SetPMeter function from the sample database to your form module. I have attached a modified database, with comments interspersed in the code.
    Attached Files Attached Files

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    Silly me <img src=/S/bash.gif border=0 alt=bash width=35 height=39> , Thanks

  8. #8
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    On testing the progress bar, I felt a little un easy with it.
    The repaint looks very cheesy, (for use of a better word) so.
    I decided to use the MSoft Progress bar 6.0 and followed the instructions from MSDN.
    One problem.
    The instructions are for A97.
    It worked fine for a while, so I decided to import all into a new database. (I do this regularly for compacting purposes. ).
    Now

    When I Debug, I get the attached error.
    I know its a problem with DAO but forget how to remedy it.
    Attached Files Attached Files

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Progress-Status Meter (A2000)

    It's a references problem, not with DAO, but with the Progress bar.
    Since you refer to ProgressBar in your code, you must set a reference (in Tools/References... from any module) to the Microsoft Windows Common Controls 6.0 library, of which the ProgressBar is part. You'll have to use the Browse... button to locate the library. The file is named MSCOMCTL.ocx and it probably resides in your system folder (on my machine, it's C:WinNTSystem32). You can either look up the exact location in your old database (Tools/References... again; if you select Microsoft Windows Common Controls 6.0, you'll see the path), or do a search from your start menu for MSCOMCTL.ocx.

  10. #10
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    Thanks once again.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Progress-Status Meter (A2000)

    Additional note: the Microsoft Windows Common Controls are not part of Office Pro, as far as I know - they come with Office Developer Edition and with Visual Studio 6 (Visual Basic 6). So if your database will be used on PC's with just Office Pro, you'll need to include MSCOMCTL.ocx in your installation.

  12. #12
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Progress-Status Meter (A2000)

    Ditto

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •