Solved

Progress Meter

Posted on 2004-04-27
12
739 Views
Last Modified: 2008-03-10
Using MSAccess 2002

I want to be able to open a form "Customers", but as it is opening I want to display a progress meter (lots of data to load). The source code for the progress meter is below, however, I do not know how to modify the code so as to function properly. Need help...

Private Sub Read_Click()
    Me.Status.Caption = "Reading"
    Screen.MousePointer = 11
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim Counter As Long
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Customers", dbOpenSnapshot)
    rs.MoveFirst
    While Not rs.EOF
        CurrentRecordID = rs!CustomerID
        ProgressBarB.Width = (ProgressBarA.Width / rs.RecordCount) * rs.AbsolutePosition
        Me.Repaint
        rs.MoveNext
        For Counter = 1 To 750000: Next
    Wend
   
    If rs.EOF Then
        ProgressBarB.Width = rs.RecordCount
        Me.Repaint
        CurrentRecordID = ""
        Me.Status.Caption = "Done"
        ProgressBarB.Width = 0
        Me.Repaint
    End If
   
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    Screen.MousePointer = 0
End Sub
0
Comment
Question by:CatDaddy2003
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10928955
I would say, you first need to set a min and max

min would be 1
max would be recordcount

when updating progressbar,you dont change the width but the value

e.g.
progressbar.min=1

rs.MoveLast
progressbar.max= rs.Recordcount
rs.MoveFirst


then in code do this

progressbar.value = ....
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10928968
I suppose you could add a counter in it as well

e.g.

dim lCounter as long


progressbar.min=1

rs.MoveLast
progressbar.max= rs.Recordcount
rs.MoveFirst
lCounter=1

    While Not rs.EOF
        CurrentRecordID = rs!CustomerID
        ProgressBarB.Value = lCounter
        Me.Repaint
        rs.MoveNext
        lCounter=lCounter+1
    Wend



I THINK THAT IS HOW IT SHOULD BE
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10928980
Personally I use just two rectangles (one backgound and boxShow that's "moving") and this code:

    dblI = 0
    dblIs = Forms(strFormname).boxBack.Width / rsI.RecordCount
    rsI.MoveFirst
    While Not rsI.EOF
       dblI = dblI + 1
       Forms(strFormname).boxShow.Width = dblIs * dblI
       Forms(strFormname).Repaint
       DoEvents
       ....
      Wend

Clear ?

Nic;o)
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 8

Expert Comment

by:dds110
ID: 10928982
So, what is the code doing?  Giving an error?  Hanging?  Nothing at all?

First thing that caught my eye was this line:

For Counter = 1 To 750000: Next

Why do you need a counter.  From what I can see this line doesn't do anything for you.  In addition, are you using the Progress Bar ocx control or some other control?
0
 
LVL 8

Expert Comment

by:dds110
ID: 10928996
Ah, disregard my comment.
0
 

Author Comment

by:CatDaddy2003
ID: 10929072
Let me start ALL OVER...

The code above works just fine. But, it is triggered from a command button "Read" on a form named "Progress Meter Form". What I need to be able to do is trigger the "Progress Meter Form" from the command button that is opening the form "Customers"...

Then display the form "Customers"...
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10929188
could you not put it in the Form_Load function of Customers?
0
 

Author Comment

by:CatDaddy2003
ID: 10929211
Let me do that, and I'll let you know what happens...
0
 

Author Comment

by:CatDaddy2003
ID: 10929265
What I did was Property: OnLoad: DoCmd.OpenForm "Progress Bar Form"

All that did was open both forms, "Progress Bar Form" and "Customers"
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10929716
ok, in the code for customers

first line in Form_Load

Minimise the window
I think its DoCmd.Minimize

then run your code

then when finished, restore window (DoCmd.Restore I think it is)

what you could do though perhaps, if above dont work, is use the timer of the customers form to display your progress bar instead of having a seperate form
0
 

Author Comment

by:CatDaddy2003
ID: 10933292
How do I use the "Timer to display the progress bar" instead of having a separate form?
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 10933592
in the form_load you set the form's timerinterval

e.g.
Private Sub Form_Load()
     Me.TimerInterval = 3000  'every 3 secs
End Sub

then in the timer func, here I am displaying a msg
Private Sub Form_Timer()
    MsgBox "Hello"
End Sub


you can mod it so you can update progress bar
so when you reach end, terminate timer,progressbar and contine
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 86
Access 2016 - query 23 59
zero pad a access form field 2 15
How Do I Select a Record using a Primary Key 3 28
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

786 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