M
Mike
I had a Paradox database called Rolodex that I imported
into Access. When I did this it asked me if I wanted to
create a Primary Key field and I said yes. Access
created a Auto Number column and set it up as the Primary
Key.
After creating the database I decided that I wanted the
Company field to be the Primary Key so I deleted the Auto
Number column and then set the Company field up as the
Primary Key. In design view it tells me that the Company
field is Indexed (No Duplicates).
I thought the Primary Key was always supposed to be
sorted. If I add a record it does not automatically sort
the database alphabetically in the Company field. In
order to get the records sorted by Company name in the
database I have to Compact and Repair the database.
I realize that I can sort the records by using the Sort
Ascending button on the toolbar but I actually want the
records sorted in the database because I am writing a
Word VBA program that populates a ListBox with the
Company names and I want them sorted alphabetically. If
I just use the Sort Ascending button it will look sorted
when viewing the database in Access but when the Company
names are brought into the Word VBA ListBox they are
listed in the same order that they are saved in the
Access database.
When I add a new record in Access shouldn't it
automatically be sorted by Comapny which is the Primary
Key?
Is there any way to force it to automatically sort the
records even though the record was added using a Word VBA
program?
The record is currently being added using DAO although I
could change it to ADO. When I try using the
Recordset.Index type statement it tells me that Company
is not an Indexed field. Is that why the records are not
sorted automatically when I add a new record using Access?
Mike
into Access. When I did this it asked me if I wanted to
create a Primary Key field and I said yes. Access
created a Auto Number column and set it up as the Primary
Key.
After creating the database I decided that I wanted the
Company field to be the Primary Key so I deleted the Auto
Number column and then set the Company field up as the
Primary Key. In design view it tells me that the Company
field is Indexed (No Duplicates).
I thought the Primary Key was always supposed to be
sorted. If I add a record it does not automatically sort
the database alphabetically in the Company field. In
order to get the records sorted by Company name in the
database I have to Compact and Repair the database.
I realize that I can sort the records by using the Sort
Ascending button on the toolbar but I actually want the
records sorted in the database because I am writing a
Word VBA program that populates a ListBox with the
Company names and I want them sorted alphabetically. If
I just use the Sort Ascending button it will look sorted
when viewing the database in Access but when the Company
names are brought into the Word VBA ListBox they are
listed in the same order that they are saved in the
Access database.
When I add a new record in Access shouldn't it
automatically be sorted by Comapny which is the Primary
Key?
Is there any way to force it to automatically sort the
records even though the record was added using a Word VBA
program?
The record is currently being added using DAO although I
could change it to ADO. When I try using the
Recordset.Index type statement it tells me that Company
is not an Indexed field. Is that why the records are not
sorted automatically when I add a new record using Access?
Mike