By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,214 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,214 IT Pros & Developers. It's quick & easy.

How to move last while inserting into a table?

P: 18
Hi all,

I am using the following piece of code to insert records into a table.Sometimes it is inserted at the bottom,sometimes at the middle and sometimes at top of the table.

[HTML]Private Sub Command383_Click()
Dim Db As Database
Dim rs As DAO.Recordset
Dim strsql As String
txtMessageTest = ""
Set Db = CurrentDb
Set rs = Db.OpenRecordset("casedetails", dbOpenDynaset)
rs.MoveLast
DoCmd.OpenForm "frmZoomTest", , , , , acDialog
If Not txtMessageTest = "" Then
strsql = "insert into casedetails (casenumber,casedetails,currentuser) values(" & Val(Me!CaseNumber) & ",'" & txtMessageTest & "','" & gfncCurrentUser & "')"
Db.Execute strsql
subCaseDetails.Requery
Else
MsgBox "cancel Selected"
End If
rs.Close
Set rs = Nothing
Set Db = Nothing[/HTML]

Need to know what should be done to insert records always at the last?

Thanks,
Bibek
Oct 8 '08 #1
Share this Question
Share on Google+
1 Reply


DonRayner
Expert 100+
P: 489
Since MS Access does not apply record numbers to any records that you create, the table will be not be in the order created but in the order sorted.

If you want everything to appear in the order that it's entered you will have to either

1. add a primary key thats set to a sequential autonumber and sort on that or

2 add a date/time field with it's default set to now() and sort on that.

Don
Oct 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.