Excel Running Access - Returns No Results on 1st Go

AccessNub

Registered User.
Local time
Today, 15:05
Joined
Jul 22, 2006
Messages
71
Hi all,

I wrote some code in Excel to open and run a module in Access. The code executes, but when I check the results I get no records, however if I just step back 1 line and rerun the query, I get records. Alternately, if I run the code twice it will get results the 2nd time.

The OpenCounter opens a Session in the terminal screen then performs a macro that writes to a temporary table.

Here is the code:

Code:
Dim db As ADODB.Connection, Rst As ADODB.Recordset
Dim Acc As Access.Application

Set db = New ADODB.Connection
db.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBPath
Set Rst = New ADODB.Recordset

Set Acc = GetObject(DBPath).Application
Acc.Run "OpenCounter", "ENROLL"

StrSQL = "SELECT tbl_Hold.* FROM tbl_HOLD"
Rst.Open Source:=StrSQL, ActiveConnection:=db, CursorType:=adOpenForwardOnly, LockType:=adLockOptimistic, Options:=adCmdText

Debug.Print Rst.EOF
If Not Rst.EOF Then...

One thing I tried with limited success was to tell the OpenCounter to open and close the table after it was done writing to it, but that seems like a lazy solution and it also doesn't always work.

Any ideas? TIA
 
Ok, I am going to blame network lag.

I added a couple of 1 second waits between queries and it seems to be happy now.
 

Users who are viewing this thread

Back
Top Bottom