Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delay code execution or run it at certain time? 1

Status
Not open for further replies.

anaguib

MIS
Oct 25, 2005
6
CA
I have a big collection of records in an Access database and in "Current" procedure there is a big chunk of code that takes long when it runs. When I am just navigating from one record to another, the whole code in "Current" runs before I can move to the next record! This takes long time and makes navigation really slow. I thought of using the "TimeValue" function and "OnTime" to delay running the code in "Current" for few seconds when I am navigating quickly ... But, discovered that "OnTime" function doesn't exist in Access VBA like it exists in Excel VBA! Do you have a way I can make navigation faster or find similar function in Acces VBA that delays or controls when codes is executed to solve this problem?
Many thanks :)
 
Thanks, Tom.

Ironically, it was comments like "let's just scratch it onto the cave wall with mammoth blood" that led to my departure from that company.

You've made my day.



John

Use what you have,
Learn what you can,
Create what you need.
 
When I say "don't make a lot of confusing code" I am not advocating to start writing all records down with pen and paper. I am saying the code should be clean, efficient, and straight forward.

The Current event should never be a place to put complex, long-running code. There is no sense in loading all the data until the user has found the record he wants to update.

The suggestion of using a dropdown to navigate to the record is a good one, but I would add to it to take the code out of the Current event and put it into some sort of LoadData subroutine. I would then call the LoadData procedure after the dropdown was clicked.

If for design reasons we still want the user to be able to navigate one record at a time, then I would return to my original idea of adding a Load or Refresh button that would call the LoadData procedure.

John, I can tell by your code that you are an experienced programmer and it wasn't really your suggestions I was commenting on. I was just trying to point out that the whole "timed update" idea was unneccessarily complex, when there are simpler design solutions.

Simpler designs have less bugs, are easier to update, and are more quickly understood by the next guy who has to work on the program (which could be me or you).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top