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.Execute "INSERT INTO Temp_Table (Temp_Field) VALUES (1);"
Set dbs = Nothing
queryAccess = "Select * from Temp_Table"
If DataEnviron.rsBrw_Access.State = 1 Then
DataEnviron.Commands("Brw_Access").CommandText = queryAccess
Set dtg_Access.DataSource = DataEnviron
dtg_Access.DataMember = "Brw_Access"
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!
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
delay (5) where ever you need to delay, It will then delay for 5 seconds before it continues.