[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

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.
0
JamieRhodes
Asked:
JamieRhodes
5 Solutions
 
naivadCommented:
list1.requery isn't working for you?
0
 
naivadCommented:
Private Sub Form_Activate()
    List1.Requery
End Sub
0
 
jjafferrCommented:
Try it either On Got Focus
Or
On Active
Or On Current

me.ListBoxName.requery
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
will_scarlet7Commented:
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.
0
 
will_scarlet7Commented:
You should also be able to us the form's "On Activate" event to trigger the requery.
0
 
will_scarlet7Commented:
OK that's the same as what naivad suggested. (sorry I need to work on my reading skills)
0
 
stevbeCommented:
You could update it in the Form_AfterUpdate event in frmDepressionAdd or from Form_Close.

Steve
0
 
jutaylorCommented:
on frmDepressionAdd try:

Private Sub cmdOK_Click()  'the button that the user clicks after adding the new record
    Forms!f_Depression.Form.Controls!lstForms.Requery
    DoCmd.Close acForm, "frmDepressionAdd"
Exit Sub
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now