Please Help!!!! Trouble creating/using dbase III indexes 
Author Message
 Please Help!!!! Trouble creating/using dbase III indexes

Hi,

I have 2 questions that all pertain to dBase III files:

1st - How do I create an index on several fields - lets say firstname,
lastname, address, city so that it sorts by firstname first, then lastname,
then address, etc.

2nd - I have a dbase file I'm opening with VB5 and DAO.  I need to index on
certain fields for sorting, etc.    There are 2 fields in this particular
table: Name and Phone.  I wanted to try to order the resultset by the phone
number, so I am trying the following code to index on the phone field.  I make
sure that there are not any indexes or other files corresponding to this
database.

Here's my code for opening the file and creating the index.

    dim  db_phone as database
    dim td_phone as tabledef
    dim idx_phone as index
    dim rs_phone as recordset    

    strDatapath = "c:\dbase\phone.dbf"
    Set db_phone = OpenDatabase(strDataPath, False, False, "Dbase III")
    Set td_phone = db_phone.TableDefs("phone")

    Set idx_phone = td_phone.CreateIndex("phone")

    With idx_phone
        .Fields = "phone"
        .Primary = True
    End With

    td_phone.Indexes.Append idx_phone

    Set rs_phone = td_phone.OpenRecordset(dbOpenTable)

   <loop to pull data>

However, when I go through the recordset, it is still sorted by name.  I need
to be able to sort different databases by different fields!

Do I need to re-open the database after the index is created?

Thanks for any help you can give.  
--Kent



Sat, 24 Jun 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Using DBase III index in VB5

2. VB4.0 16-bit using dBase III Indexes

3. Using indexes with dBase III

4. Open DBASE III DATABAE PLEASE HELP!

5. OPENNING DBASE III DATABASE...PLEASE HELP!

6. DBase III & VisBas 5 Pro FindFirst Trouble

7. Question on dBASE III and indexes

8. dBASE III indexes

9. dBASE III/IV & FoxPro Index files

10. Indexing atached dBase III tables

11. dBase III Index and VB4

12. dBASE III indexes

 

 
Powered by phpBB® Forum Software