Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2010
    Posts
    185

    Custom Progress Bar On Load Event and On Timer

    Hello,

    I have a splash screen, and for aesthetic purposes only I would like to create a custom progress bar using an image. The splash screen has a timer event to disappear and load the main form. The timer interval for that is 6000. I would like to have a custom progress bar that starts when the splash screen loads, with a timer interval of 5000 thus leaving the splash screen up for an additional second after the progress bar reaches 100%.

    I watched a youtube video here - https://www.youtube.com/watch?v=0SqcA9vIRs0
    This seemed like it was getting me into the right area for what I wanted to do but could not figure out how to get it to automatically start when the splash screen loads and progress on a timer.



    Can anyone point me in the direction or teach me what I need to do here. I like the idea in the video of setting up the image to be the progress bar.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    I stopped looking at the video when I realized this was probably just a form with a colored box whose length changes in steps because I've done this before.
    Assuming your splash screen is a form, then it has an open event. Use that event to run your bar code and forget about the timer event since it only needs to run once. I can provide an example if you wish.
    Maybe I'll go back and finish the video to compare to my own example.

    EDIT: part way through, decided to jump back here to say if you're distributing your db, I'd forget about using an image for the bar. Looks fancier, but distribution issues will probably arise. You can accomplish the same thing with a colored rectangle.
    Last edited by Micron; 03-23-2018 at 08:42 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2010
    Posts
    185
    Micron,

    Yes can you please provide an example?

    I am not distributing the DB - It will have only 1 end user ever so I would like to use a picture. I could just use the Microsoft ProgressBar Control, version 6.0 under the active X controls if I didn't care what it looked like. As I mentioned, I want this for aesthetics only so the picture usage is ideal.

    And yes, the splash screen is a form.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    There are many examples of progress bars available online
    Attached is one of mine
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    Some notes re the attached db that I threw together for you:
    A simple form, popup & modal (otherwise, what's the point if user can move the focus to something else during the progress?).
    The form has no borders so as to eliminate the white window header you get in version 2016. Boxes provide a thin ad-hoc border.
    Box0 is the width-wise resizing colored but flat borderless bar. Box4 has sunken format to make the "control" look more 3 dimensional and lies underneath Box0. That provides a sunken base which appears to be filled incrementally, but it's just the width of the other box that's changing.
    Box0 starts out at 0" width upon form opening and begins to lengthen by the specified amount (sngWidth + 3.75) in each iteration up to 6 seconds (Start + 6) or until the 2 widths are equal. At the end of the loop, a label appears. This would probably be the point at which you'd invoke the Close event for this form, but I put the label there to denote the loop is finished, plus it has a double click event if you want to fire the code again without having to close/reopen the form.
    You would substitute Box0 for your image control and modify its width property in the same manner.

    The video code is fine, but more complex than what you need since you are not dealing with a variable number of tasks for which you can calculate a percentage of completion. That form will repaint the line in coarser "chunks" thus doesn't suffer from screen flicker. The one I attached does flicker, and the flicker is the same regardless of whether I use DoEvents or Repaint (interestingly enough, you can find web pages that say don't use DoEvents because it uses too much processor power, yet their code example uses DoEvents).

    So you have a decision to make aside from substituting an image control - re-writing the code to widen the control in chunks, or settle for some flicker. If flicker is ok, it presents another aspect you may not like. Depending on factors like hardware, network traffic, demand on the pc resources, etc. the bar might not make it to the end one day, and the next, a second elapses between the end of its progress and when the form closes. At least I made sure the code doesn't widen the bar beyond the length of the underlying box. I think we've all seen a progress meter indicate a finished process and the process takes (sometimes much) longer to finish, so from my perspective, that wouldn't be an issue.

    If flicker is not ok and you decide to widen in chunks, then you'd widen the bar x units, repaint the form, then pause - rinse and repeat. A simple public pause function in a standard module will do the trick, which I included in the attached. You'd call it like Pause 3 for 3 seconds. So 5 chunks would have to complete in 5 seconds if the form is to close 1 second later. If that were the case, it would be Pause 1 each time.

    I attempted to save as an older version (2003 I think) in case others want to look at it. See what you think.

    ProgBar.mdb
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2010
    Posts
    185
    Thanks for the examples guys. It has been a while since I have been in Access and am struggling with this.
    Attached is the image I want to use.

    I would like the progress bar (using that image) to start on form load and when it has ran to 100% I would like that form to close and a second form to open.

    Can someone give me an example of that using this image please?
    Attached Thumbnails Attached Thumbnails 2018-03-24_14-28-50.png  

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    Pretty sure it can't be a png file. While jpg is supposed to work, experts have stated elsewhere that they are converted behind the scenes into bitmaps. So if you can convert and upload a bitmap, that would be better. You might as well make it a lot wider while you're at it, so that it doesn't have to tile so much.

    You should provide the db, or a copy of one, that contains the form you want to use, as well as the form you want to open next. Otherwise, you'll probably be back seeing as how we can't know which forms you're talking about.
    EDIT: never mind the conversion, I took care of it.
    But a copy of the db or at least the relevant parts of it would be good...
    Last edited by Micron; 03-24-2018 at 08:42 PM. Reason: added info

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Sorry to tread on your toes micron but a PNG image file is fine.
    A BMP file would also be perfect. As you said, JPG files wouldn't give good quality results due to their lossy nature

    I've updated my example to use your image and just used 'Stretch' mode to fit the space allocated
    I've also modified the example so you can set the number of steps required from the form itself with default 600

    I've left my original magenta bar on the form (unused / hidden) in case you want to revert to that

    To use in your own database, copy the modProgressBar module and the progress bar controls from my form
    Define the number of steps required (iCount) - e.g. based on events in a lengthy routine

    The progress bar and associated text is normally hidden.
    Add the line 'StartProgressBar' to your code to trigger it
    After each event, add the line 'UpdateProgressBar'
    When done, add the line 'HideProgressBar'
    That's it!
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2010
    Posts
    185
    ridders52,

    That looks great. I don't know why I am having issues. This seems like something I should be able to figure out but can't seem to. I am going to equate it to my lack of VBA over the last few years.

    Can you show me an example of the progress bar running from 0 to 100% as soon as the form opens - form close at 100% and new form opening?
    Lets call the first form frmSplash and the second form frmMaster.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    I've never run a progress bar when a form loads but it should work as long as it's the last item in the form load event

    Add the line SetupProgressBar as part of your form load code, run the events you are showing progress for ....adding UpdateProgressBar after each step.
    After the last step, add these lines

    Code:
    HideProgressBar
    DoEvents
    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "frmMain"
    NOTE if it doesn't work well in form load,try moving the code to Form_Activate instead.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    I thought it was supposed to be a splash screen? That requires it to be the form that's set to open when the db opens. If one wishes to suppress any Access application splash from older versions additional steps are required. Honestly, I haven't been paying attention after upgrading to 2016. Can't say if there is an application splash now.

    Anyway, as fine as the latest fix may be it doesn't help to open the next form, which is why I asked for a db. Perhaps all will be fine regardless. As for png I guess the ms website info is either out of date or applies to something other than Access.

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Hi micron
    I'm assuming the OP was referring to his own startup form called frmSplash
    Not sure why you said this doesn't help open the next form, FrmMain.

    If he was referring to the Access splash form, that can be hidden by placing a small BMP file in the database folder with the same filename as the database.
    The BMP file doesn't actually have to contain an image.

    Attached is a modified version which starts the progress bar when the startup form loads then closes it at 100% & opens another form frmMain
    Attached Files Attached Files
    Last edited by isladogs; 03-25-2018 at 09:29 AM. Reason: Added another example
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    Not sure why you said this doesn't help open the next form, FrmMain.
    I guessed I missed the part where prior to post 12 your code closes the startup/splash form and opens the next form. Sorry if that's the case.
    that can be hidden by placing a small BMP file in the database folder with the same filename as the database.
    The BMP file doesn't actually have to contain an image.
    That's what I had in mind. Given how much OP seems to be struggling with getting the chain of events working, my thoughts were to have his form working along with the closing of it and then the opening of the next form. Perhaps he will be successful with your efforts. Good job, by the way.

    I don't know if I learned anything from this exercise, but it seems that using a very short TimerInterval value on a form timer does away with the screen flicker. That's interesting if it's the real reason.

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Remember that I only used a form timer event in my example to keep the code simple
    In normal use the progress bar is updated after each event completion
    e.g. relinking all tables in backend databases / running an annual update to fields in a large number of tables.
    Therefore flickering isn't relevant in such cases

    The 'smoothness' of the progress bar will depend on:
    a) how many steps are involved
    B) the time taken for each step (likely to vary in real life situations) - if VERY fast or VERY slow it won't appear to flicker but if JUST slow enough to be distinguishable as separate steps it will appear to flicker - just like video or TV or even -book animation
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,826
    Remember that I only used a form timer event in my example to keep the code simple
    Well, it seemed to take all the flicker out of my example, so for me, that's a bit of a take-away. Prior to that, all in one procedure in a Do While loop I was executing an If block if the bar width was less than the underlying box width, incrementing by n and mixing in DoEvents before and sometimes after this, plus repainting the form. Nothing I tried was as smooth as using a form Timer event with an interval of 100. I could only guess that by terminating then re-running the box sub (because the timer is calling this code every 100 milliseconds or whatever it is) that it results in less flicker. Actually, it eliminated it. Either that, or the fact that the timer allowed me to drop the loop had something to do with it. Sounds like you're saying you usually do this without using a Timer event but don't get any flicker. That's interesting.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA for Progress/Load bar on my Form
    By nwood in forum Programming
    Replies: 6
    Last Post: 07-14-2017, 05:59 PM
  2. Access as event timer?
    By Jennifer Murphy in forum Access
    Replies: 1
    Last Post: 01-31-2014, 08:30 PM
  3. Timer Event Code Stops After First Run
    By burrina in forum Forms
    Replies: 3
    Last Post: 02-19-2013, 09:46 AM
  4. countdown timer and progress bar
    By yigitki in forum Programming
    Replies: 5
    Last Post: 11-16-2011, 01:20 PM
  5. Timer Event - Why does this happen
    By Rhino373 in forum Programming
    Replies: 2
    Last Post: 05-26-2011, 07:18 PM

Tags for this Thread

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