Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progress bar in MS Access

Tags:

vba

ms-access

I have a query running in Microsoft Access 2010 and it takes over 30 minutes to run normally. I would like to present the end user with some status of the query. A progress bar would be nice but not required. Access seems to be poorly threaded and locks up tight during the execution of the query, negating any updates I try. While I'd rather whip out VS and write my own app to do this, I'm forced to use Access.

I used to run this from a batch script which populated the database but I'd like to have it all self-contained in Access. To be specific, the "query" is really a VBA script that pings a series of hosts. So I'm not too concerned about optimizing the time per se but simply about letting the end user know it hasn't locked up.

like image 494
Menefee Avatar asked Aug 14 '12 16:08

Menefee


People also ask

What is the status bar in access?

A Status bar is a horizontal window at the bottom of a window, and it displays various kinds of status information. On the Access Status Bar, you can switch the active window between one of the available views by using the controls available on the status bar.

Which bar displays the progress bar?

In this example, modeless progress is shown in the address bar. Otherwise, if the window has a status bar, display the modeless progress in the status bar. Put any corresponding text to its left in the status bar. In this example, modeless progress is shown in the status bar.


1 Answers

I often do something like this

Dim n As Long, db As DAO.Database, rs As DAO.Recordset  'Show the hour glass DoCmd.Hourglass True  Set db = CurrentDb Set rs = db.OpenRecordset("SELECT ...")  rs.MoveLast 'Needed to get the accurate number of records  'Show the progress bar SysCmd acSysCmdInitMeter, "working...", rs.RecordCount  rs.MoveFirst Do Until rs.EOF     'Do the work here ...      'Update the progress bar     n = n + 1     SysCmd acSysCmdUpdateMeter, n      'Keep the application responding (optional)     DoEvents      rs.MoveNext Loop rs.Close: Set rs = Nothing db.Close: Set db = Nothing  'Remove the progress bar SysCmd acSysCmdRemoveMeter  'Show the normal cursor again DoCmd.Hourglass False 

Note: Of course you must do the work programmatically for this to work. You cannot watch a runnging query in code or the like in Access. Possibly you could split the work of your slow query into smaller pieces, in order to get the chance of updating a progress bar. But you can always show the hour glass; this tells the user that something is happening.

like image 165
Olivier Jacot-Descombes Avatar answered Sep 19 '22 22:09

Olivier Jacot-Descombes