Solved Hello everyone: After the dlookup process, I want to add the seriousness records to the top of the table (1 Viewer)

Matin_Murad

Member
Local time
Today, 14:18
Joined
Jul 1, 2020
Messages
37
I want to send new records to the top of a table.. more clarification was written on a form
 

Attachments

  • New Record To Up Table - ABCD.accdb
    544 KB · Views: 106

plog

Banishment Pending
Local time
Today, 16:18
Joined
May 11, 2011
Messages
11,646
I can't open your database--says I need a newer version of Access. However, I do know that no matter what version of Access you use (or any other database system) there is no "top" of a table. Tables have no order, they are just buckets of data you throw data into. There's no first, no second, no 38th record in a table. No record comes before or after another record in a table. The data is just in a table. Records don't go into a specific spot in the table, they either go in or they don't.

Now, when you pull data out of a table (with a query) or load them into something (a form or a report) you can specify the order in which they appear as long as you explicitly use code that provides the order they are to adhere to.

So, if you want them to display in a form in a particular order, you can use the OrderBy property of the form:

 

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:18
Joined
Aug 30, 2003
Messages
36,126
I can open your db but I'll echo what plog said. You can do that by adding a "WhenSaved" date/time field to tabl2 with a default value of Now() and sort by that.
 

mike60smart

Registered User.
Local time
Today, 22:18
Joined
Aug 6, 2017
Messages
1,913
Hi Martin
I can open the database but I do not have a clue what you are trying to do here.
 

Matin_Murad

Member
Local time
Today, 14:18
Joined
Jul 1, 2020
Messages
37
Sorry, I want to sort on the new record form to the top
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:18
Joined
Feb 19, 2002
Messages
43,301
Sorry, I want to sort on the new record form to the top
Plog explained in great detail that there is no concept of "top" when it comes to a table or query for that matter. If you want the record that was most recently added to appear at the top of the list when viewed on a continuous form, then you can order by the autonumber, assuming it is assigned sequentially rather than randomly or you can add a saved date field as someone suggested. The saved date will make old records sort to the top if they have been updated so your results would be different.

Order By MyPrimaryKey Desc

or

Order By MyDateUpdated Desc

If you only care about the date the record was added, then in the table design add a default of Now() to the CreateDT column you will add. If you care about the last updated record, then name the column UpdateDT and in the BeforeUpdate event of the form, populate the date.

Me.UpdateDate = Now()

PS:
The new record row is ALWAYS at the bottom of the list and this cannot be changed. So in the AfterUpdate event of the form, add a requery to get Access to sort the list and put the new record at the top.

Me.Requery

If you want the "new" record to actually be at the top, the method to do it is to create two subforms. The first will show the "new" record only and the second, which should NOT be updateable, will show all existing records. Another possibility is to use an unbound form to add new records. I don't like that method and don't use it for a variety of reasons.
 

Matin_Murad

Member
Local time
Today, 14:18
Joined
Jul 1, 2020
Messages
37
Thanks for all the replies, it was helpful from the replies to the best solution
 

Users who are viewing this thread

Top Bottom