Saving a new record in a form in Access 2000

P

pvp

I have the following code to save a newly-entered record,
dating back to Access 97:

'
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
'

I am told there is better way to do it from Access 2000
onwards. What is the 'modern' equivalent?

Also, when I have entered a new record, I find that the
records 'behind' the form are still sorted apart from the
newest record, just entered. Is there a quick and easy
way to resort records after each new record has been
saved?

Thanks.
 
V

Van T. Dinh

Equivalent statement:

DoCmd.RunCommand acCmdSaveRecord

You can use the Form_AfterUpdate Event to re-order the Records:

* If you originally use the Order By clause in the RecordSource Query, you
can requery the Form using:

Me.Requery

* If you originally use the OrderBy Property (and OrderByOn Property), use:

DoCmd.RunCommand acCmdApplyFilterSort

Either way, Access will make the first Record of the new Recordset as the
current Record. If you need another Record or the new Record to be the
current Record, you need to use GoToRecord Method to make another Record the
current Record. For this reason, I don't normally worry about re-ordering
while the user is in data entry mode.

Alternatively, you can create a CommandButton on the Form so that the user
can simply re-order when he/she wants rather than automatically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top