Updating a form

  • Thread starter Thread starter Pete Davis
  • Start date Start date
P

Pete Davis

On my form, I have a listbox which lists some related records.

Underneath is a button that opens the form to add/edit/or delete these
related records. When the updates are done, how do I get the listbox to
re-load the records?

In other words, if I add a new related record, it doesn't show up in the
main form unless I leave the record on the main form and come back.

Thanks.

Pete
 
Have you tried invoking the listbox's Requery method.

Hope That Helps
Gerald Stanley MCSD
 
Okay, that would probably work, but how do I get access to the form from the
button click event?

Also, I'm under the impression (though I might be wrong), that the
DoCmd.OpenForm method doesn't block, meaning that after I click the button,
will it wait until the form I opened to be closed before the script
continues execution or does execution continue (which is what I suspect)?

In which case, I can't do the requery from the button click event but must
find some way to do it from the second form.

Does that make sense?

Thanks.

Pete
 
-----Original Message-----
Okay, that would probably work, but how do I get access to the form from the
button click event?

Also, I'm under the impression (though I might be wrong), that the
DoCmd.OpenForm method doesn't block, meaning that after I click the button,
will it wait until the form I opened to be closed before the script
continues execution or does execution continue (which is
what I suspect)?

This depends upon whether the form being opened is modal
(in which case excution of code in the calling form is
supended) or not.
In which case, I can't do the requery from the button click event but must
find some way to do it from the second form.

This would be the way to do it. You can reference the listbox
on the first form using something like
Forms("{yourformname").Controls("{yourlistboxname}").
Requery
 
Back
Top