Updating a Listbox after changes in another field

Tezcatlipoca

Registered User.
Local time
Today, 19:00
Joined
Mar 13, 2003
Messages
246
Hi all,

Hokay, I've been toying with this one for a while now, but would greatly appreciate people's advice.

To keep it simple, say I have a form, frmDetails. On this form is an unbound text box, Notes, and a Listbox, ListBox, which is based on a query. The query calls all records in a table, tblNotes, and the first couple of words of the actual data of this field is shown in the Listbox. The user can click on any selection in ListBox, and the field Notes will automatically update itself, allowing the user to read the full notes. So far, so good.

Now let's say I have the Me.Notes.Locked = True property set, and have a button (btnEdit) whose OnClick property sets it to False, thus allowing the user to click a button and edit a record. I also have a second button, btnSave that does some quick validation checks, saves the changes, then switches the field's locked status back to True.
In addition, I have Me.Notes.Locked = True in the form's OnOpen and OnCurrent properties, ensuring that the fields stays locked with the exception of using the Edit button.

All of this works perfectly.

The problem is that when the user has edited the notes, and clicked Save, I want the contents of the Listbox to get automatically updated, showing the changes made by the user. Everything updates properly if you quit the form then return to it, but is there a way to dynamically update?
 
Last edited:
Hello Tezcatlipoca!
Look at "Demo2ListBoxA2000.mdb" (attachment, zip).
It is not exactly what you need, but I think you can adapt it as you need.
 

Attachments

you can update the listbox with
listboxname.requery

so you get

docmd.openform "popup_notes"
listboxname.requery

BUT

you need to open the popup as a dialog form, so that the requery doesnt fire UNTIL you close the popup form

ie
docmd.openform "popup_notes",acdialog
listboxname.requery

or, you need some code to check when the popup form is closed

ie
docmd.openform "popup_notes"
while isopen("popup_notes")
doevents
wend
listboxname.requery

this latter version lets users do other things, and the popup form can be resized while it is open, but there is no intrinsic isopen function, so you have ot write your own
 
Ah, fantastic thanks Gemma. Everything now behaves properly, with a log being saved and the listbox instantly updating to show the new log.
 

Users who are viewing this thread

Back
Top Bottom