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.

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.


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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

756 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