The Linux Page

Ensure rendering happens in MS-Access

Today I bumped in another problem: I want to show my user a message saying that I'm terribly busy looking for data in the database. Because I use ODBC with QuickBooks (QODBC to be precise), the system is somewhat slow. Therefore, it can take a little while and people just can't wait and they start clicking everywhere like crazy. That's a big problem...

Since I cannot close the form (i.e. the form searches and then renders the results on screen!), I decided to have a hidden Label with a message "Searching... Please Wait...". That message is to be shown by setting the Visible parameter of the label to True (I make sure it is false when the form is opened.)

So I tried...

  1. SearchLabel.Visible = True
  2. SQL = "SELECT ..."
  3. Display Results
  4. SearchLabel.Visible = False

This works, in theory. The problem, with this code, is that the label is shown AFTER the SQL code is executed.

The way to fix this would be to either pause for a little while (but that's a waste...) or ask Access to execute all the events, especially the event of showing the search label. The first solution requires a call to Sleep() which is not readily available in MS-Access. The second solution, which frankly I could not even remotely think would be possible is not only available, but it is dead easy with one very simple Application call: DoEvents

So right after setting the Visible parameter of the SearchLabel to True, call DoEvents and voila! You see that label immediately!

  1. SearchLabel.Visible = True
  2. DoEvents
  3. ... ' Do your work
  4. SearchLabel.Visible = False