Kamis, 04 Juni 2020

Re: [MSAccessProfessionals] Updating a list box after new record entry

hi Russ,

> "How can I save the record without closing that form?"

manually, you can click on the record selector box (where the pencil is, indicating there are unsaved changes. If it doesn't show or you want the keyboard shortcut, it is Ctrl-S

To automatically save a record when a particular value is changed, on that control AfterUpdate:

Me.Dirty = False

this is a somewhat obscure way to save a record because it isn't very intuitive, but good to memorize ;)

no need to test if the record is dirty first because the code runs on the AfterUpdate event of a control, so it obviously changed ;)

However, that won't requery a combo box. To do that, you can put this code on the Form AfterUpdate event:

Me.combo_controlname.requery

WHERE

combo_controlname is the NAME property of the combo box (or listbox)

kind regards,
crystal

free code you can use in your projects
https://msaccessgurus.com/code.htm


On 6/4/2020 4:47 PM, Russ wrote:
Even if I go to a different record the new record is not shown in the List Box.  How can I save the record without closing that form?

Russ

That code goes to a new record but the record is not saved until you leave the record by closing the form, moving to a different record, or performing an action that saves the record. 
 
Duane

Tidak ada komentar:

Posting Komentar