Looping Through A Recordset
Couple of thoughts.
What cursor are you using. ForwardOnly is by far the most efficient
rs.Open src, cnn, adOpenForwardOnly
Secondly, you could try do the selection with a recordset filter rather than
in the SQL. The SQL query should be considerably faster, but you will need
to test it to see whether the recordset filter is quicker than a query
select.
Finally, although I haven't tried it myself to check if it is more
efficient, you could load the recordset into an array suing the GetRows
method, and then loop through the array
aryData = GetRows(src)
--
HTH
are you using
Bob Phillips
"ibeetb" wrote in message
...
I am looping through a recordset but it is taking FOREVER. It is a DB
field
that I am trying to collect a Disitinct list from. Here is the code: By
the
way, this code is tunning in Excel using ADO...
By the way, there are a total 0f 55000 records to loop through. Anyway I
can
make this faster. It takes 5-6 minutes to create a distinct recordset
'Fills the Teams list box with available team names
src = "SELECT DISTINCT
public.tts_time_weekly_report_display.team_name "
src = src & "FROM public.tts_time_weekly_report_display "
src = src & "WHERE
public.tts_time_weekly_report_display.tts_time_wee k_worked '12/31/2002'
"
rs.Open Source:=src, ActiveConnection:=cnn
Do While Not rs.EOF
frmTeams.lstTeam.RowSource = rs
frmTeams.lstTeam.AddItem rs.Fields("team_name").Value
rs.MoveNext
Loop
|