Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Loop in an Index Table 1

Status
Not open for further replies.

regava

Programmer
May 24, 2001
152
US
Access 2002 - I have the following routine:

Code:
.
.
strSql = "tblX"
set deb = currentdb()
set rec = db.OpenRecorset(strSql)
rec.index = "IndexA"
rec.Seek "=", strZ
if Not rec.nomatch then
  rec.edit
  .
  .
  rec.update
end if
rec.close
set rec = Nothing
[\code]

I want to loop thru it since the index allows duplicates.
I do not want to searche the whole table since the chance of hitting a record in the table is less than 1% and the table is rather large.
Any help is appreciated.
 


Please post MS Access questions in one of the MS Access forums like Forum705.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Try
Code:
strSql = "Select * From tblX Where SomeField = '" & strZ & "'"

set deb = currentdb()
set rec = db.OpenRecorset(strSql)
Do Until rec.EOF
  rec.edit
  .
  .
  rec.update
  rec.MoveNext
Loop
rec.close
set rec = Nothing
Then you should get only those records where your condition is satisfied and you don't need to do the search using seek.

 
Golom Thank you for your wonderful suggestion. I works.
Sorry I did not reply quicker but I was away for the last 3 days. You deserve a start.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top