Solved

Can't get listbox on a form to requery

Posted on 2014-02-24
4
461 Views
Last Modified: 2014-02-25
I have a form which contains a listbox.  When the use double-clicks in the listbox a 2nd form opens for data entry.  When the 2nd form closes I have this code on the onclose event but the listbox on the main form is not "refreshing".  It looks empty yet if I close the main form and re-open the main form the listbox records are there.

Here's my onclose code of the 2nd form:

    Forms!frmDailyFinishingInput.[List0].Requery

What am I doing wrong?

--Steve
0
Comment
Question by:SteveL13
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 250 total points
ID: 39883905
Forms!frmDailyFinishingInput![List0].Requery

You have a dot where you should have a bang.  I would also check the spelling of everything.  Is the control on the main form because if it is on a subform, the syntax would need to change.

Forms!frmDailyFinishingInput!YOURSUBFORM.Form![List0].Requery
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 250 total points
ID: 39884187
Here is some actual code that requeries several listboxes on a subform of the current form.  I set a Form variable to the subform to make the code more compact.  You could just substitute the form name for the Me keyword:

         Set frmSub = Me![subAssignmentTypesTeamAndIndustry].Form
         frmSub![lstToSelectTeam].Requery
         frmSub![lstSelectedTeam].Requery
         frmSub![lstToSelectIndustryTypes].Requery
         frmSub![lstSelectedIndustryTypes].Requery

Open in new window

0
 
LVL 84
ID: 39885487
Note too that you must be careful when referring to Subforms:

Forms!frmDailyFinishingInput.YourSubformCONTROL.Form.etc

"YourSubformCONTROL" is the name of the Subform CONTROL on frmDailyFinishingInput. It may or may not be named the same as the form you're using as a SourceObject, so be sure to verify this.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 39886662
If you use a naming convention, you will never have to guess about whether a name refers to a form, control or other object.  That is one of the advantages of using a naming convention.  I have an add-on that semi-automatically applies the Leszynski Naming Convention (LNC) to database objects and controls.  Here are links for downloading it:

Access 2000-2003 version:
http://www.helenfeddema.com/Files/code10.zip

Access 2007-2010 version:
http://www.helenfeddema.com/Files/code63.zip
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

760 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

26 Experts available now in Live!

Get 1:1 Help Now