473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,398 developers and data experts.

Access Progress Form

TheSmileyCoder
2,322 Expert Mod 2GB
Usually as developers we do our best to ensure that function calls occur almost instantaneous with no discernible wait time for the user.

If a process takes more than a quarter of a second, or maybe half a second we can turn the mouse pointer into the hourglass (or rotating circle on later versions of windows) with this simple code
Expand|Select|Wrap|Line Numbers
  1. Docmd.HourGlass=True
and when we are done, turn it off with
Expand|Select|Wrap|Line Numbers
  1. Docmd.HourGlass=False
However, if we have a longer running process, especially one that takes more than 10 seconds we risk the user getting impatient, killing the application, with all the risks of a mid-process termination. To buy a bit of patience we can try a popup form that just says "Please wait", but we can actually do better than that. We can use a progress form that not tells the user what is going on, but also shows to the user that there IS progress, that the application has not died.

With that in mind, I set out to create something more advanced than a simple "Please wait..." form, and this is the result.
http://www.youtube.com/watch?v=J4YAtJH57Gw

The downloadable sample consists of 5 objects. A progress form (TSC_ProgressFormSimple) that handles the graphics, a class module (TSC_PF_Simple) that handles all the logic, 2 utilities modules and a form (frm_Test) to try and illustrate intended usage.
You will need to import all but the frm_Test into your application.

To start up the progress form you simply dimension a new class object:
Expand|Select|Wrap|Line Numbers
  1. 'Init progress form
  2.   Dim oPF As TSC_PF_Simple
  3.   Set oPF = New TSC_PF_Simple
We now want to set the title, and the initial task text, and then show the form
Expand|Select|Wrap|Line Numbers
  1. 'Show the form
  2.   oPF.Title = "Importing Objects" & vbNewLine & "Please wait..."
  3.   oPF.UpdateTask 0, "Preparing Import"
  4.   oPF.Show
Each time we have progress to report we simply call the UpdateTask method, supplying the new percentage as a number between 0 and 1 (1 being 100%) and optionally the text to display.
Expand|Select|Wrap|Line Numbers
  1.   oPF.UpdateTask 0.5 , "Importing"
When you are all done and wish to close the form, you can just set the object variable to nothing, and the class will take care of the rest. In this case I included it in the clean up procedure:
Expand|Select|Wrap|Line Numbers
  1. Exit_Sub:
  2.   'Cleanup
  3.   Set oPF = Nothing
The class has some built in timers to prevent flickering, and to give the user the chance to see the process finish before the form is closed.

Another option is to allow the user to cancel a process (well technically in-between processes when the form is updated). If you set the AllowCancel to true, a cancel button becomes visible and the user can now attempt to cancel. Note that click events only take place when the progress form is updated.

This progress form uses the code by Stephen Leban to autosize the text frames if needed. This means you can use long text strings without missing out.

I hope you enjoy this free sample. Remember that feedback and comments is the fuel that keeps the fire lit.

The problem remaining is that a progress form such as this is only usefull when you have a alot of opereations to run sequentially. It is not that usefull if all you have is a single big query that ages to run, since the progress form can only update graphics, in between queries or other function calls.
Attached Files
File Type: zip TSC_Progress_Simple.zip (103.4 KB, 1385 views)
Apr 14 '13 #1
3 9575
Lysander
344 Expert 100+
I like this! I have several long processes in my databases, some can take 30 mins to run and use something similar, but nowhere near as sophistaced. Two questions. What happens if your process should happen to fail, i.e. does the form disappear. (In my simple version it does not, and the user is locked out of access:( Secondly, can you say what versions of Access this runs on.
Apr 16 '13 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Lysander
Note that this only works if the process can be divided into chunks, since you need to modify your code to include the commands to update the progress monitor. So if you have a single query that takes 30 mins to run then there isn't really much to do, unless you can divide the query into smaller parts.

@Question 1: If the progress class object is declared
Expand|Select|Wrap|Line Numbers
  1. Dim oPF As TSC_PF_Simple
within the scope of a single procedure, then as the procedure is exited (by intent, or by error) the object will fall out of scope, and during termination it should close the form automatically.

@Question 2: The download is stored in 2002/2003 format. It was created with Access 2010, which in some cases means it can't be opened by earlier versions, but I have not used anything fancy so I believe it should work in 2002 as well. Reports of either success or failure using 2002/2003 are appreciated.
Apr 19 '13 #3
Seth Schrock
2,965 Expert 2GB
I just implemented this on a new database that I'm working on. It works great and I think that my boss will really enjoy having it so that there is something to look at besides a spinning wheel.

Thanks for sharing Smiley.
May 15 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: El_Embozador | last post by:
Hi , please can you tell how i can print an MS ACCESS Report form visual basic, i ned a sample code .. Thanks
1
by: bailee220 | last post by:
I have included the following code to open an Access database form from within an exsisting Access database. But when I run the code, it appears that it opens the database because in windows...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
4
by: Chris Lane | last post by:
I have a form declared like this in the html <form id="SearchResults" method="post" runat="server" name="frmMain"></form> I don't see the form anywhere in the codebehind and I am not able to...
7
by: Pepi Tonas | last post by:
I have a form that takes some time to load because it has to populate some Data. I was trying to display a form on top of it with an activity bar so that user can see that something's going on. ...
3
by: Gerrit Snel | last post by:
We have a question but we're in doubt if it's even possible or not. The question is as follows: Is it possible to access a form using a string literal, and if so yes? We want to use...
3
by: emajka21 | last post by:
Hello, and thank you in advance for trying to help me. I am trying to create an access 2000 form without using the wizard. It just doesn't seem like I can the level of complexity I want out of the...
1
by: Mike Thompson | last post by:
I have an event handler defined within a class. It has the following signature: static void XYZ_EventHandler (object sender, XYZEventArgs e) From within this event handler, I want to access...
0
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
5
by: sphinney | last post by:
Basic question: Does anyone know how to go about adding a control to an Access 2007 form that will allow viewing a Word 2007 document? Reason for asking: My office is about to receive 100+/-...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.