Form Opener/Parent?

S

Simon Harris

Hi All,

I'm sure this will be a common query, how ever after an hour of Googling
I've not found anything useful!

I have a form which has a listbox, with customers in it. My user will either
double click a customer, or hit the 'new customer button', which will either
open a customer record for editing, or open the form ready for a new record
to be entered (DoCmd.OpenForm stDocName, datamode:=acFormAdd).

Problem is, when they have finished adding/editing, they close the form
which then obviously shows them the original form with the listbox, which
does not reflect the additions/changes.

I tried using the 'Got Focus' method of the parent form, adding a
listbox.requery - This didnt seem to do anything.

Having a web development background, I also thought of using parent/opener
value of the customer edit form - Although I'm not sure these exist!?

Any other ideas?

THANKS!
Simon.
 
S

schasteen

In the close event of the form that they add the customer in put:
Forms![MainFormName]![ListBoxName].requery
 
T

TC

A small problem with that approach, is the the second form must now
know the name of the first form & the listbox on it. A better approach
might be, to pass those two names as a parameter to the second form, so
that it does not need to "code in" those names.

Alternatively, you could put: me![ListBoxName].ReQuery in the
/first/ form, immediately after the docmd.openform that opened the
second form. This assumes that you have opened the second form using
docmd parameter values which ensure that the openfom statement does not
return until the called form has been closed by the user.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
S

Simon Harris

Thank you both for your posts, Forms![MainFormName]![ListBoxName].requery
works just fine.

Regards,
Simon.
 

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