Quote:
Originally Posted by jimatqsi
I have the query "ICOnHandByAlias", which is saved in an Access 2003 frontend. I can open this query and get a result set of 4,900+ rows in about 1 second. The table being accessed is in a SQL backend.
I have a vba routine which puts together the code to pull one of these rows, as follows:
Select * from ICOnHandbyAlias WHERE ([ItemAlias]="MD-BC1/OB25")"
The actual vba code I am using is
strSQL = "Select * from ICOnHandby Alias "
strCriteria = " Where ([ItemAlias] = """ & me!strProductID & """) ;"
Set rsItemWH=dbs.OpenRecordset(strSQL & strCriteria, dbopendynaset,dbseechanges)
This last statement, the SET statement, takes 6 seconds to return the result.
What's causing this 1-second query for 5000 results to take 6 seconds to return one row?
Thanks,
Jim
Hello Jim, try the following to see what happens.
- Create an Index on the [ItemAlias] Field in SQL Server.
- Open the Recordset as a Snapshot and not Dynaset if it is OK for it to be Read Only.
- Eliminate the dbSeeChanges Option.
P.S. - How and where are
dbs and
rsItemWH Declared?