Once a Form recieves Focus refresh a listbox

Posted on 2004-08-19
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

Assisted Solution

naivad earned 50 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 50 total points
ID: 11846271
Try it either On Got Focus
On Active
Or On Current

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.
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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 50 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 50 total points
ID: 11846468
You could update it in the Form_AfterUpdate event in frmDepressionAdd or from Form_Close.


Accepted Solution

jutaylor earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now