Solved

Once a Form recieves Focus refresh a listbox

Posted on 2004-08-19
8
294 Views
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.
0
Comment
Question by:JamieRhodes
8 Comments
 
LVL 4

Assisted Solution

by:naivad
naivad earned 50 total points
ID: 11846239
list1.requery isn't working for you?
0
 
LVL 4

Expert Comment

by:naivad
ID: 11846250
Private Sub Form_Activate()
    List1.Requery
End Sub
0
 
LVL 27

Assisted Solution

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

me.ListBoxName.requery
0
 
LVL 15

Expert Comment

by:will_scarlet7
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.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 15

Expert Comment

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

Assisted Solution

by:will_scarlet7
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)
0
 
LVL 39

Assisted Solution

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

Steve
0
 
LVL 1

Accepted Solution

by:
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
    Forms!f_Depression.Form.Controls!lstForms.Requery
    DoCmd.Close acForm, "frmDepressionAdd"
Exit Sub
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

708 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

17 Experts available now in Live!

Get 1:1 Help Now