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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO - using the indexes of the table

Status
Not open for further replies.

Crookshanks

Technical User
May 18, 2004
296
NL
Hello there,

I've got a very small and probably very simple question. In my database "contact" I've got two important fields:
- Organization
- Name_contact
In the table definition I created two indexes named after the above mentioned fields.

Depending on a variable the index is set to
RsCon.index = "Organization" or rsCon.index = "Name_Contact"

Now I want to loop through the table in the order of the index, so i wrote:
Code:
     Do While rsCon.EOF = False
       If rsCon![Selected] = True Then
            'do some kind of action     
       End If
       rsCon.MoveNext
    Loop
but the order in rsCon.Index is not reflected in the Loop. Question: what am I doing wrong?

I realiaze that it is probably very simple but I am stuck (damn those monday mornings).... Any help appreciated.

Kind regards,
 
Sorry, my bad. The above works, but I had to restart Access.
 
It may work now but there's no guarantee that it will always work.

Indexes are used to search the database but there is no assurance that records will be returned in Index order if you don't use an Order By clause when you retrieve them.
 
Thanks for your tip. I will implement a query instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top