Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can't get listbox on a form to requery

Posted on 2014-02-24
4
Medium Priority
?
482 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 40

Accepted Solution

by:
PatHartman earned 1000 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 1000 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 85
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 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