ODBC Queries

G

Guest

Hi.

I use a form to run certain ODBC queries to an Oracle 7.3 database. These
reports can take a couple of hours to run and during this time the screen
often goes blank (Access does not respond).

Is it possible to refresh the form while the report is running? I have
tried placing DoEvents in the code but it doesnt work.

Any ideas?

Cheers,
Steve
 
G

Guest

Sorry, I am unable to follow the link due to restrictions on my works system.
Could you paste the code?

Is it possible to mix ADO and DAO code?
 
S

Stefan Hoffmann

hi,
Sorry, I am unable to follow the link due to restrictions on my works system.
Could you paste the code?

Is it possible to mix ADO and DAO code?
Yes.

Taken from Elmar Boye:

' A class modul named clsExecute
Option Explicit

Dim WithEvents mcnnAsync As ADODB.Connection
Dim mcmdAsync As ADODB.Command
Dim mShowMsgBox As Boolean

Private Sub Class_Terminate()
If Not mcmdAsync Is Nothing Then
mcmdAsync.Cancel
End If
End Sub

Public Sub ExecuteSQLAsync(cnn As ADODB.Connection, _
strSQL As String, _
Optional ShowMsgBox As Boolean = False)

Set mcnnAsync = cnn
Set mcmdAsync = New ADODB.Command
With mcmdAsync
.CommandTimeout = 0
.CommandType = adCmdText
.CommandText = strSQL
Set .ActiveConnection = cnn
End With
mcmdAsync.Execute Options:=adAsyncExecute + adExecuteNoRecords
mShowMsgBox = ShowMsgBox
End Sub

Public Sub Cancel()
If Not mcmdAsync Is Nothing Then
If (mcmdAsync.State And adStateExecuting) = adStateExecuting Then
mcmdAsync.Cancel
End If
End If
End Sub

Public Property Get IsExecuting() As Boolean
If Not mcmdAsync Is Nothing Then
IsExecuting = (mcmdAsync.State And adStateExecuting)
Else
IsExecuting = False
End If
End Property

Private Sub mcnnAsync_ExecuteComplete(ByVal RecordsAffected As Long, _
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, _
ByVal pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, _
ByVal pConnection As ADODB.Connection)
If pConnection = mcnnAsync Then
If mShowMsgBox = True Then
MsgBox "Finished"
End If
End If
End Sub


' Testcode:

Dim oExecute As clsExecute

Sub ExecuteLong()
Dim cnn As ADODB.Connection

Set oExecute = New clsExecute
oExecute.ExecuteSQLAsync CurrentProject.Connection, _
"WAITFOR DELAY '00:00:15'", True

Do While oExecute.IsExecuting = True
Dim nCount As Long
nCount = nCount + 1
If nCount Mod 100 = 0 Then
Debug.Print "Waiting " & nCount
End If

If nCount Mod 10000 = 0 Then
'oExecute.Cancel
End If
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top