Solved

Can't get listbox on a form to requery

Posted on 2014-02-24
4
468 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 35

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 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