If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Time delay

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-11-04, 04:12
mijuani mijuani is offline
Registered User
 
Join Date: Aug 2004
Posts: 4
Time delay

Is there any way to hold the execution of a portion of your procedure for a few seconds? What my procedure does is to insert a new record into an Access table and then refresh the data grid. Unfortunately, the data grid is not refreshing because I noticed that it starts refreshing even before the record is added to the Access table. I was hoping to insert a line in my procedure asking it to wait for a few seconds before refreshing the data grid.

Below is an example of my procedure:
Dim dbs As ADODB.Connection
Set dbs = New ADODB.Connection
dbs.ConnectionString = "Provider=MSDASQL.1;Data Source=ABC"
dbs.Open
dbs.Execute "INSERT INTO Temp_Table (Temp_Field) VALUES (1);"
dbs.Close
Set dbs = Nothing
queryAccess = "Select * from Temp_Table"
If DataEnviron.rsBrw_Access.State = 1 Then
DataEnviron.rsBrw_Access.Close
End If
DataEnviron.Commands("Brw_Access").CommandText = queryAccess
DataEnviron.Commands("Brw_Access").Execute
Set dtg_Access.DataSource = DataEnviron
dtg_Access.DataMember = "Brw_Access"
dtg_Access.Refresh
Reply With Quote
  #2 (permalink)  
Old 08-11-04, 08:45
Pat Phelan Pat Phelan is online now
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I haven't tried this, but would it work if you posted the refresh instead of calling it directly? That might induce just the right amount of delay, without actually wasting any time.

-PatP
Reply With Quote
  #3 (permalink)  
Old 08-11-04, 21:59
mijuani mijuani is offline
Registered User
 
Join Date: Aug 2004
Posts: 4
I'm sorry but what do you mean by posting the refresh?
Reply With Quote
  #4 (permalink)  
Old 08-23-04, 20:05
AceOmega AceOmega is offline
Registered User
 
Join Date: Apr 2004
Location: Arizona
Posts: 49
TRy This

Dim Delay as Integer
Dim CurrentTime as Integer
Dim StartTime as Integer

StartTime = Timer
Delay = StartTime + 10 'Number of second you want to pause
CurrentTime = StartTime

While CurrentTime <= Delay
CurrentTime = Timer
WEnd
Reply With Quote
  #5 (permalink)  
Old 08-24-04, 20:44
SCIROCCO SCIROCCO is offline
Registered User
 
Join Date: Mar 2004
Location: www.scirocco.ca
Posts: 346
Declare your connection object at the module level using the WithEvents command like this:

Private WithEvents dbs As ADODB.Connection

Now your connection object has an Event called ExecuteComplete

Put the refresh code in that event. In this manner the refresh will happen exactly when the execute has completed.
__________________
http://www.scirocco.ca/images/banner...occobanner.gif

Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

Or try our Ask An Expert service to answer any of your questions!
Reply With Quote
  #6 (permalink)  
Old 08-25-04, 13:42
Lord_Saroman Lord_Saroman is offline
Registered User
 
Join Date: Aug 2004
Posts: 16
Sub Delay(pdblSeconds As Double)
On Error Resume Next
Const OneSecond As Double = 1# / (1440# * 60#)
Dim dblWaitUntil As Date
dblWaitUntil = Now + OneSecond * pdblSeconds
Do Until Now > dblWaitUntil
Sleep 100
DoEvents
Loop
End Sub

Then type:
delay (5) where ever you need to delay, It will then delay for 5 seconds before it continues.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On