Results 1 to 14 of 14
  1. #1
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109

    How to measure procedure's progress in Vba?


    Hi,

    I'm planning to add a progress bar between clicking "Save data" and msgbox "Data has been saved". Of course a lot of things is happening in-between, but let's call it unimportant here. I have already procedure prepared, that increases the progress bar (made with use of a rectangle) to a given percentage value (from 0 to 100%). All works good. Till now I only used it during my script performance by measuring how many records it's been through/how many left. Is there any other way to measure for example form's loading state? Is there any method I can use?

    Robert

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    None that I know of. Access does this somewhat in the application status bar at bottom of application window.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could have a Pop Up modal form launch. It could read something like "Please wait patiently here while this form loads." Then, in the form that is loading, place some code in the On Current event to check if the Modal form is open and then close it.

    I guess you could add some lines of code your various procedures to update your modal form. "Just Starting", "Not Complete Yet", "Halfway There", etc.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    If you know how many records will be processed, you could break it into a few loops and pop up your modal form with the relevant number as ItsMe has suggested. You 'll need code to close /open control the form.
    You may want to consider the DoEvents instruction to give control to the OS from Access (Access is singled threaded-- the key issue when trying to run a progress bar).

    Did you get your rectangle approach from DataPig's site? There is one there.
    Can you post the code you decide to use?

  5. #5
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109
    Hi Guys,

    I can't remember already where I borrowed this approach from (I've read lots of different sites lately). I'll place the code a bit latter.
    @ItsMe I like your idea. It would be even better if I could hook it up with some animation (not necessarily related to the real progress of code's run)

    Robert

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by robs23 View Post
    ... (not necessarily related to the real progress of code's run)...

    Robert
    Like June mentioned, don't think that is an option. Will have to use similar approach to counting records during update, etc.

  7. #7
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109
    Nah, I think I'll be better off with a simple showing a kind of loop or something like that. It doesn't necessarily indicate any progress, just that there is something going on so the user knows it hasn't frozen. It's something like a circle spinning round (and not indicating any percentage) that you can find it e.g. browsers. Do you have any ideas how I can achieve that in Access? Of course I don't stick to this circle, any animation that shows work is in progress might be good here.

    Robert

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I do not play around with that sort of thing but, you could adjust the size of a control based on the iteration count of a recordset during DAO. As the count grows closer to the Recordcount, so do the size of a control with a darker back color. Basically, as the code executes, certain lines trigger the growth or change of something to simulate automation. I know I have seen threads about here. I think June7 helped someone with one recently.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Yep. https://www.accessforums.net/access/...bar-44952.html

    Search form on keyword progress to see more possible relevant threads.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109
    Sorry for digging it up.
    I actually still haven't found suitable solution. My best shot so far seems to be using WebBrowser object (ocxWebBrowser) to load animated gif from the local drive. It works ok if I just run the form that contains WebBrowser object - animation is smooth etc. On the other hand, when I open this form from code (it is supposed to be animation to keep the user "entertained" during code execution after all), the image loads, starts playing and freezes after a second. It won't replay till my procedure finishes and close the form. What can I do to make it play smoothly during the code is running?

    Robert

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I think this might have something to do with timer event. But really, you are just taking processing power from the main procedure and extending the processing time.

    What are you doing that requires so much time? Let them be hypnotized by hourglass spinning. Switch cursor to hourglass at beginning of procedure then switch back at end.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Did you look at the sample at DataPig?
    Access is single threaded, so making it do 2 things at once would really be stopping then doing 2, then stopping 2 and doing 1.....

  13. #13
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    As said in https://www.accessforums.net/program...tml#post242441 use the timer event. As June7 said, you slice up the one thread access uses, so it switches back and force between its current job and the animation. Afaik this isn't really a problem as long as the time used for the animation is minmal, like updating every 0.5 second or something like that. Of course, the update step it self should be as fast as possible, to not steal to much of the processor time from the real job you need to do. There are good reasons for access to not support real multithreading out of the box. It is possible, if you know how to, but you shouldn't do it if you don't know how to do it. There are many pitfalls when writing multi threaded applications and not knowing what you do.

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    More info on Access Progress bars here

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 07-04-2014, 12:20 AM
  2. Units of measure converter
    By gaker10 in forum Programming
    Replies: 5
    Last Post: 07-02-2014, 12:20 PM
  3. Weights and Measure Query
    By The Grand Pooh-Bah in forum Queries
    Replies: 2
    Last Post: 02-20-2013, 08:25 AM
  4. Handeling Multipule Units of Measure
    By Waldenbound in forum Database Design
    Replies: 1
    Last Post: 09-02-2011, 08:24 AM
  5. Unit of Measure
    By Lghtning4u in forum Forms
    Replies: 0
    Last Post: 07-25-2007, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums