Once a Form recieves Focus refresh a listbox

Posted on 2004-08-19
Medium Priority
Last Modified: 2008-03-06
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.
Question by:JamieRhodes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Assisted Solution

naivad earned 200 total points
ID: 11846239
list1.requery isn't working for you?

Expert Comment

ID: 11846250
Private Sub Form_Activate()
End Sub
LVL 27

Assisted Solution

jjafferr earned 200 total points
ID: 11846271
Try it either On Got Focus
On Active
Or On Current

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

LVL 15

Expert Comment

ID: 11846279
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.
LVL 15

Expert Comment

ID: 11846318
You should also be able to us the form's "On Activate" event to trigger the requery.
LVL 15

Assisted Solution

will_scarlet7 earned 200 total points
ID: 11846323
OK that's the same as what naivad suggested. (sorry I need to work on my reading skills)
LVL 39

Assisted Solution

stevbe earned 200 total points
ID: 11846468
You could update it in the Form_AfterUpdate event in frmDepressionAdd or from Form_Close.


Accepted Solution

jutaylor earned 200 total points
ID: 11848925
on frmDepressionAdd try:

Private Sub cmdOK_Click()  'the button that the user clicks after adding the new record
    DoCmd.Close acForm, "frmDepressionAdd"
Exit Sub

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question