Sleep vs Timerinterval

Posted on 2011-03-02
Last Modified: 2012-08-13
Which is better (or are they the same) Sleep or Timerinterval? I have a form where onCurrent I need to establish some variables, count the # of days based on a couple dates, and a couple of other calculations.

I also have code behind the column headings (on a continuous form) to sort the contents of the column --

if me.orderby="FieldName" then me.orderby="FieldName DESC" else me.orderby = "FieldName"

The onCurrent bogs down the sort -- so I put the culprit code in a timer -- but it still seems that things keep running too slowly.

I have tried Application Echo and the DBEngine.Idle dbRefreshCashe ---

Nothing seems to work.

This is not a large db. It's a FE/BE (.accdb) with about 8 users consecutively. The BE never grows beyond 30mb.

The form is bound because it requires real-time updates available to all the users.

Any suggestions that would help me speed things up would be appreciated.

Thanks a lot!!

Question by:Ei0914
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2

Expert Comment

ID: 35018788
Sleep performs its code after a certain time - once; TimerInterval repeats the process after specified time, again and again.
Probably best to use OnForm, since this will run the code every time the form is opened - don't use OnTimer since this can cause issues.
LVL 75
ID: 35018854
But why would the sorting be affected but the code in the current event, which is only going to execute when you open the form and/or go to a different record.  You wouldn't be clicking the column sort during that time, right?
Also ... this is why I started using datasheet views instead of continuous forms a long time ago, to take advantage of all the built in right click sort/filter etc.  I used to do the column sort thing also.

Overall, not seeing why you would need a timer or Sleep for any of this ...?

Author Comment

ID: 35018956

When you resort a form the OnCurrent event fires because a new record becomes "Current" upon sort.

This is a Dispatch Management system with several dispatchers moving through the records and assigning drivers, calculating charges/fees based on # days out (when initial order was entered to when the dispatcher says the move is completed), etc. It's a truly real-time application.

We thought this might be a networking issue: so, they replaced the NIC card. This client gets access to their server (as they are a branch office) through Remote Desktop. Initially, when I took over support of the application, all the users had their own copy of the front-end, all in the same directory on the server.

So I created a batch file to copy the FE to the users local C: drive (in their Remote Desktop Session) which may not have any impact since the C: drive in that scenario is virtual -- and the processing is probably dragging down server performance regardless of where it is --- am I right about that or not? I'm not a network specialist and they don't have one on staff to help with me that question.

I wouldn't need a Timer if the performance of the form was so poor. I'm trying to put some of the calculation off to the side if possible (which is why I am using the Timer) ---

It is also a tabbed form - and as they change tabs the recordsource changes -- a delay there is acceptable. But in one tab -- where there are only 30-40 records, you'd think there were a million records in the view the way the form is performing.

I want to eliminate anything I may be doing before putting the "blame" on the network or hardware. I would appreciate any suggestions on how best to handle this with regard to the remote desktop too.

Thank you so much for responding, and for your help. I'm ready to pull my hair out.

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.


Author Comment

ID: 35018972
Opps : I wouldn't need a Timer if the performance of the form was'nt so poor.

Accepted Solution

ComputerAidNZ earned 250 total points
ID: 35019012
When  I'm troubleshooting code such as you are doing I put the code in a button and fire it manually, iron out all the bugs, then move the code to an event, then delete rthe button.  BUt the manual firing will show if it is the code of the event that is causing the error.  PS I've had numerous issues with MS Access timer events and coding issues that are OFTEN cured by re-creating the form from scratch and slowly adding the code to the new form.  What happened I don't know, but it obviously solved the issues MANY times
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 35019182
Well, I have to agree that ...  the Timer event can be problematic at times.

"- am I right about that or not?"
I really don't know.  Really have not done anything with RD ... one client has a Terminal Server setup and that is fast.

What is the nature of the code running in the On Current event?

Author Comment

ID: 35020045
Thanks you guys/gals(?) -- I'll try that. I'll split the points. I appreciate your help. If you can think of anything else, I'd be happy to hear about it.


Author Closing Comment

ID: 35020084
Rec'd great direction. Thanks as always!
LVL 75
ID: 35020134
guy :-)

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question