Re: How to use ADO Seek Method With Multiple Columns
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 17:23:22 +0100
Orlanzo wrote on Tue, 13 Jun 2006 06:46:01 -0700:
hi All,
I've got a small table in a jet database with three fields (rpt_pd,
beging_dt, and end_dt) All fields are indexed separately and I have a
compound index named "Reporting_Period" which is comprised of both
begin_dt and end_dt. The table contains 13 rows.
I'd like to use the Seek method to locate the row where a date falls
between begin_dt and ed_dt. It isn't clear to me how this would be
accomplished. Initially, I consisdered using the Find method; however, it
doesn't support a complex search criteria.
How could I rewrite the following to use the Seek method? Or, is their
another solution I should consider?
adoRst.Find("Begin_dt <= #07/25/2005# AND End_dt >= #07/25/2005#")
Kind regards,
Orlanzo
Neither Find or Seek will help you here. Can you not using a query with a
WHERE clause to narrow your results?
The other solution would be to loop through the recordset and compare the
column values, but this is very inefficient. However, if you can't add a
WHERE clause to your recordset source, you might not have much choice, eg.
adoRst.MoveFirst
Do Until adoRst.EOF
If adoRst("Begin_dt") <= CDate("07/25/2005") And adoRst("End_dt") >=
CDate("07/25/2005") Then
'do something with the row, eg. add to a disconnected recordset if you
need to do further manipulation
End If
adoRst.MoveNext
Loop
Dan
.
- Prev by Date: Re: ADO ODBC timeout via VBA
- Next by Date: String as output from SP in C++
- Previous by thread: Re: ADO ODBC timeout via VBA
- Next by thread: Re: How to use ADO Seek Method With Multiple Columns
- Index(es):
Relevant Pages
|
|