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

Record order in continuous form 2

Status
Not open for further replies.

pauldt123

Technical User
Mar 23, 2006
21
GB
Hi guys,

Quite a simple one I think (but evidently not simple enough!). I have a continuous form which displays records from a comments table, at present the form displays the oldest record at the top and the newest at the bottom. How would i go about reversing the order so the most recently dated comments appear at the top?

I inherited the db from another employee and there seems to be some pointless SQL scattered around the place, for example the code below was in the recordsource for the form, why not just set the table as recordsource? Am I missing something here?

SELECT Comments.[Cast ID], Comments.Comment, Comments.Author, Comments.Category, Comments.Date FROM Comments;

Many thanks in advance

Paul
 
The SQL "scattered" around is probably not pointless. For example, in the case you hve presented the SQL is the source for the form. While you could probably get away with setting it to the table name as you suggest, you will not get the descending date sort you are looking for.

Change the recordsource for the form from the above SQL you posted to this:

SELECT Comments.[Cast ID], Comments.Comment, Comments.Author, Comments.Category, Comments.Date FROM Comments ORDER BY Comments.Date DESC;

That should sort your records by newest date first.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
It is usually recommended that forms are based on queries. You can use the SQL to order your records:

[tt]SELECT Comments.[Cast ID], Comments.Comment, Comments.Author, Comments.Category, Comments.Date FROM Comments ORDER BY Comments.Date Desc;[/tt]

Or you can use OrderBy and set OrderByOn to True.

 
Thanks for the swift replies guys, a star for each of you for your help.

I'd already tried ORDER BY comments.date Descending, so close and yet so far!

Thanks again

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top