Once a Form recieves Focus refresh a listbox

frmDepression allows a user to select a form from a list box then by command button choose add, edit or delete.  The add button opens up  frmDepressionAdd where the user inputs data then has the option to choose add or cancel.  My question is once this new entry is entered  the user is back to frmDepression.  I want the list box to automatically refresh once the form is in focus and am having trouble with this.
Who is Participating?
jutaylorConnect With a Mentor Commented:
on frmDepressionAdd try:

Private Sub cmdOK_Click()  'the button that the user clicks after adding the new record
    DoCmd.Close acForm, "frmDepressionAdd"
Exit Sub
naivadConnect With a Mentor Commented:
list1.requery isn't working for you?
Private Sub Form_Activate()
End Sub
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

jjafferrConnect With a Mentor Commented:
Try it either On Got Focus
On Active
Or On Current

Ok. Here is something I just found in the microsoft access help that may shed some light on why it is not working:

    "A form can receive the focus only if it has no controls or if all visible controls are disabled. If a form contains any visible, enabled controls, the GotFocus event for the form doesn't occur."

So sinc you have at least one control (your listbox) on your form nothing will happen in the forms OnGotFocus event because the form never has the focus. You will need to move it to the control's OnGotFocus event if you want it to fire.
You should also be able to us the form's "On Activate" event to trigger the requery.
will_scarlet7Connect With a Mentor Commented:
OK that's the same as what naivad suggested. (sorry I need to work on my reading skills)
stevbeConnect With a Mentor Commented:
You could update it in the Form_AfterUpdate event in frmDepressionAdd or from Form_Close.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.