combo box -- order of list

  • Thread starter Thread starter Dave Eliot
  • Start date Start date
D

Dave Eliot

I have a combo box on a form called frmNotes. The combo box is populated
with one field -- "title" -- from a table called tblProjects which only
has two fields -- ProjectID (auto number and key) and title. As new
projects are added to the table I want the newest project at the top of
the list in the combo box. I can't seem to make that happen.

Now go ahead, somebody, and tell me how easy it is to do.

Thanks in advance.
 
I have a combo box on a form called frmNotes. The combo box is populated
with one field -- "title" -- from a table called tblProjects which only
has two fields -- ProjectID (auto number and key) and title. As new
projects are added to the table I want the newest project at the top of
the list in the combo box. I can't seem to make that happen.

Now go ahead, somebody, and tell me how easy it is to do.

Thanks in advance.

Unless you have some date/time field in your table, the word newest
has little meaning.

Add a new field to your table.
Field Name "EnterDate", DateTime Datatype
as it's default value property enter
=Now()

Save the table.
Each time you enter a new record, the date and time of entry will be
added to the record.
Then as the combo box Rowsource create a query:

Select tblProjects.Title from tblProjects Order by
tblProjects.EnterDate Desc;

As this will only effect newly entered records, you will need to
manually enter a date and time (doesn't have to be an exact date/time)
in each of the already entered records.
If you have many records you could write a procedure to do this. For
just a few, manually is just as easy.
 
If your ProjectID is incremental and not randow, you can sort on it in
descending order as the highest numbered record would be the most recent
added:
ORDER BY ProjectID DESCENDING
 
Klatuu said:
If your ProjectID is incremental and not randow, you can sort on it in
descending order as the highest numbered record would be the most recent
added:
ORDER BY ProjectID DESCENDING
That's it! Worked just fine!
Thanks.
 
Back
Top