Access vba stop screen updating

To demonstrate the principle of this technique we'll need a small example procedure that makes lots of visible changes to the Excel workbook.

You can either download the example here, or create a new blank workbook, add around five worksheets to it and then copy the code shown below into a new module.

It can be confusing and cause considerable frustration when you use a shotgun approach to the four terms.

Screen Updating = True For i = 1 To 2 If i = 2 Then Application. Screen Updating = True Msg Box "Elapsed time, screen updating on: " & elapsed Time(1) & _ " sec." & Chr(13) & _ "Elapsed time, screen updating off: " & elapsed Time(2) & _ " sec." Source: Msgbox never get executed, nor VBA shows any error - it just silently fails.

To achieve this we need to add a single line of code to the subroutine, just below the variable declarations.

It's probably also worth changing the colour that we're using so that we can see when things have changed. This time you won't be able to see the macro carrying out its tasks; once the subroutine has finished the screen will update once at the end to show you the final result.

Perhaps hiding or disabling the cursor is not the best way to achieve this end. Best regards Kev @Hack - believe me, this is a very useful piece of code.

I now need to resort them so can use refresh which leaves the cursor on the selected record. If I wanted to move down twice, I would have to find the record and select it again with requery. This is used to refresh the screen without interacting with the database. Say you have a label “Update Processing” to warn users that a lengthy process is happening.

If you set the visible property to false when you open the form, you can set it to true at the start of the update procedure. To make the screen display the change to the label use repaint after the change to visible.

Hello, I did step through the code, and it stops exactly on the line with Screenupdating = True.

However, I found the source of error - it was fail in function that do validation for auto-rules. This is not an answer; like earlier posters I am unable to get this routine to fail.


Leave a Reply