473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

delay code from executing while previously ordered actions are still being executed

This question is an outgrowth of my previous question regarding why a certain textbox wasn't updating. What happens is an addquery is called to add a record to a table and then a textbox (called Total) is set equal to a subtotal textbox (called subtotal2) calculated off that table. The problem is, the Total box reflects the Total before the new item was added. If I then manually tell it to update again a moment later it gives the correct value. So I need a code that will pause execution for a few milliseconds after the addquery is called but before the code Me.Total = Me.Subtotal2 is executed.

Here is the code:
Expand|Select|Wrap|Line Numbers
  1.     stDocName = "AddTransaction"
  2.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  3.     Me.OrderSubform.Requery
  4. ' Pause is needed here'
  5.     Me.Total = Me.Subtotal2
Oct 23 '09 #1

✓ answered by etmanage

I found the solution elsewhere, here it is:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  4.  
  5. Sub Wait(Sec As Double)
  6.   For i = 1 To Sec * 100
  7.     DoEvents           ' handle events
  8.     Sleep (10)          ' suspend process without CPU-Load
  9.   Next
  10. End Sub
Then where you want to pause you just put
Expand|Select|Wrap|Line Numbers
  1. Wait(seconds)  'where seconds is a number

1 1810
I found the solution elsewhere, here it is:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  4.  
  5. Sub Wait(Sec As Double)
  6.   For i = 1 To Sec * 100
  7.     DoEvents           ' handle events
  8.     Sleep (10)          ' suspend process without CPU-Load
  9.   Next
  10. End Sub
Then where you want to pause you just put
Expand|Select|Wrap|Line Numbers
  1. Wait(seconds)  'where seconds is a number
Oct 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lynology | last post by:
My program takes in a key pressed value from the main routine and based on the key pressed, it selects the command to be executed. The problem I have is in creating a delay timer so that a message...
1
by: lynology | last post by:
My program takes in a key pressed value from the main routine and based on the key pressed, it selects the command to be executed. The problem I have is in creating a delay timer so that a message...
6
by: adish11 | last post by:
Hi, In Web Application I would like to create delay for 30 sec in the code to enable external process to run. During the delay in application I would like to show the user message like "Please...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
4
by: Dennis Sjogren | last post by:
Greetings! First, I'm not 100% sure where to post this question. I use VB.NET for this project, but it's really a design question (a question on which method to use when solving this problem). ...
4
by: Phil Galey | last post by:
I have a routine that calls a function that returns a boolean. If I paste the function call into the immediate command window, it runs the function and returns the correct result. However, if I...
5
by: DCC-700 | last post by:
I am using ASP.Net with VB on the 1.1 Framework running on Win XP Pro. I am trying to gauge the time it takes to sort a datagrid using different code sets. But when I am debugging the page there...
37
by: ales | last post by:
Hello, I have a problem with creation of new thread. The method .Start() of newly created thread delays current thread for 0 - 1 second. Cpu while delay occurs is about 5%. Any idea? Here...
21
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.