requery a listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi to all,

I have a form with a listbox on it. When there are items ALREADY showing I
can double click on any item, open programmaticaly another form, edit the
item and close the form. On the close event of this second form I have a
listbox.requery command. As soon as the form closes my listbox updates
immediately. But not always! When there are no items ALREADY showing in the
listbox and I open the second form through a command buton (not with the
DoubleClick Even of the list box), add multiple items and then close the
form, the listbox is still showing empty. If I close the form containing the
listbox and reopen it or if I move to a different record and then return back
THEN the listbox is showing the newly added items and works as expected when
I edit them. Any clues how I can correct this behaviour?

thanks in advance, George
 
Hi George

When you open the "edit item" form, you should open it in dialog mode, by
specifying the Windowmode argument as acDialog:
DoCmd.OpenForm "MyForm", ... WindowMode := acDialog

This causes the procedure containing this line to be suspended until the
form is either hidden or closed.

Then, after the DoCmd.OpenForm, add:
Me.[MyListbox].requery

This means the listbox will not be requeried untiol after the edit form is
closed.
 

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

Back
Top